def. Checking if object is defined

The operator checks if the object is defined and returns Boolean value (true/false). The check can be performed on any object in Parser: table, string, file, object of user-defined class, etc.

def object
As undefined (not def) Parser regards: empty string, empty table, empty hash and code.

Example
$str[This is a defined string]
^
if(def $str){
    String is defined
}{ 
    String is not defined
}

Important notice: To check if code or method is defined, use operator
is, not def. Thus, ^if(def $hash.delete){-}{hash doesn't contain element delete}.
Note: a hash containing only default value is defined [3.4.5].



Copyright © 1997–2021 Art. Lebedev Studio | http://www.artlebedev.com Last updated: 24.04.2017