initialize method

initialize method

-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

initialize method
[Ruby] initialize method
What is the initialize method?
Java method
java (method)
getRequestDispatcher () method
merge method
Map method
include method
List method
puts method
About the role of the initialize method
Java method
Class method
save! method
getParameter method
[Java] method
private method
rails method
[Java] method
Ruby to_s method
Screen transition method
Binary search binary search method
Method to search
Factory Method Pattern
Rails delegate method
scan method problem
[HTTP method PATCH]
About the method
[Java] forEach method
[Practice] Map method
[Servlet] Basic method
Binary search method
Template Method pattern
Template Method Pattern
0-filled (non-zero) method
JavaSilver11 study method
keycloak test-skip method
Factory Method pattern
Ruby build method
undefined method `** _ path'error
java8 method reference
[Java] Random method
Ruby accessor method
[Java] split method
ruby map method