Error: Cannot NEW the private variable ‘{name}’ in a procedure block
A New in a procedure block names a private variable. A formal argument, or a local the
public list does not name, is private, and a procedure block allows New only for a public
variable. IRIS refuses to compile the class or routine
(ERROR #1038: Private variable not allowed). A private variable is already new when the
block is entered, so delete the New, or Kill the variable to discard its value.
IRIS rejects the example.
Class Demo.NewInProcedureBlock
{
ClassMethod Total(hours As %Integer, overtime As %Integer) As %Integer
{
New sum //! A6866
Set sum = hours + overtime
Quit sum
}
}