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
Method
Ruby Learning # 30 Initialize Method
What is the initialize method?
Java method
to_i method
getRequestDispatcher () method
merge method
include method
Abstract 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
Exception switching method
RxSwift method chain
Rails delegate method
scan method problem
Java8 method reference
[Ruby] slice method
[Ruby] Method memorandum
[HTTP method PATCH]
About the method
[Java] forEach method
[Practice] Map method
[Servlet] Basic method
variable and 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