Call a member method : getter setter « Class « Ruby
- Ruby
- Class
- getter setter
Call a member method
class Animal
def initialize
@color = "red"
end
def get_color
return @color
end
end
animal = Animal.new
puts "The new animal is " + animal.get_color
Related examples in the same category