Product Site

5.1.1.20. new

Returns a new instance of the receiver class, whose object methods are the instance methods of the class. This method initializes a new instance by running its init methods (see Section 4.2.9, “Initialization”). new also sends an init message. If you specify args, new passes these arguments on the init message.
Example 5.14. Class class — new method
/* new method example */
a = .account~new             /* --> Object variable balance=0           */
y = .account~new(340.78)     /* --> Object variable balance=340.78      */
                             /*    plus free toaster oven              */
::class account subclass object
::method init                /* Report time each account created       */
                             /* plus free toaster when more than $100  */
Expose balance
Arg opening_balance
Say "Creating" self~objectName "at time" time()
If datatype(opening_balance, "N") then balance = opening_balance
else balance = 0
If balance > 100 then Say "  You win a free toaster oven"