top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How we can declare and use a constructor in Ruby?

+2 votes
503 views
How we can declare and use a constructor in Ruby?
posted Oct 26, 2014 by Amit Kumar Pandey

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Constructors are declared via the initialize method and get called when you call on a new object to be created.

Using the code snippet below, calling Order.new acts as a constructor for an object of the class Order.
enter image description here
Initializing instance variables of the class Order.

answer Oct 28, 2014 by Kali Mishra
...