-Method to be called when creating an object from a class
python
class Food
def initialize
puts 'Initialize'
end
end
Food.new
#=> Initialized.
-The initialize method is a special method and cannot be called from the outside.
python
food = Food.new
food.initialize
#=> NoMethodError: private method 'initialize' call for #<Food:0x007gfasjfasfjas>
Recommended Posts