Explain about “initialize()” function in R?

initialize() function is used to initialize the private data members while declaring the object.

init1

With the above code, we are initializing the values of “name” and “cost” during the time of declaration.

init2

We have initialized the values of ‘500’ to cost and ‘pizza’ to name