Class: Primitive
Description
This method either returns the primitive's value, or a supplied (or implied) default value in case Primitive.exists() returns zero. This method replaces the M $GET command.
Syntax
Primitive.get(Primitive default)
Parameters
default |
The value to return if the Primitive.exists() method returns 0 (zero); that is, does not have a defined value. If not specified, the parameter defaults to null. |
Returns
The value of the Primitive, or the specified default value.
When Became Available
Profile v6.4
Example
// Simple subroutine that uses Primitive.get() to ensure
// that an optional parameter has a value
public fac(Number fac) // calculate fac!
// force (non zero) integer value
set fac = fac.get(1)\ 1
if fac < 0 quit -$$fac(-fac) // arbitrarily
if fac < 1 quit 1 // 0! and 1! both 1
quit fac * $$fac(fac-1) // use recursion
if fac < 1 quit 1 // 0! and 1! both 1
quit fac * $$fac(fac-1) // use recursion