What is the use of new and initialize in Ruby Programming?

When a class contains a method named initialize this is automatically called when an object is created using the new method. It is a good idea to use an initialize method to set the values of an object’s instance variables. The new method creates an object. Ruby executes the initialize method immediately after a new object is created.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.