Creating an Object : object Creation « Class « Ruby
- Ruby
- Class
- object Creation
Creating an Object
# You use the new method to create an object in Ruby.
class Animal
def initialize
@color = "red"
end
def get_color
return @color
end
end
animal = Animal.new
Related examples in the same category