Constructor

suggest change

A class can have only one constructor, that is a method called initialize. The method is automatically invoked when a new instance of the class is created.

class Customer
  def initialize(name)
     @name = name.capitalize 
  end
end
sarah = Customer.new('sarah')
sarah.name #=> 'Sarah'

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents