Ruby Class:
class Person
def initialize(name)
@name = name
end
def say_hi
puts "#{@name} says hi"
end
end
andreas = Person.new("Andreas")
andreas.say_hi
After writing this code in file create filename with .rb extenstion.
In you command line execute the file:
> ruby example.rb Andreas says hi
Just practice this In next post we will learn Class Inheritance.
Back to Ruby Introduction >> click

Waiting for your sessions with more advanced concepts. :)
ReplyDeleteThanks for giving feedback.
DeleteSure you will get all advanced concepts one after another.