Code: Select all
obj := {a: 3}
MsgBox not obj.HasProp('b') ? "prop not found" : !obj.b() ? "evaluation is false" : obj.b()
obj := {a: 3, b: (*) => }
MsgBox not obj.HasProp('b') ? "prop not found" : !obj.b() ? "evaluation is false" : obj.b()
a := 3
MsgBox !IsSet(b) ? "var is unset" : not b() ? "evaluation is false" : b()
a := 3, b := () =>
MsgBox !IsSet(b) ? "var is unset" : not b() ? "evaluation is false" : b()
Note that IsSet and HasProp do not evaluate, they only check to prevent errors. This is important because while HasProp and IsSet may return true, their evaluation may not.
However, since functions still return an empty string instead of unset, this is not as of great importance at the moment. (This may prevent proper chaining of functions such as a(b()) where a() uses IsSet() to define behavior.)
Code: Select all
MsgBox Type(fn()) ; String
fn() {
return ; "" empty string
}