This is because setters are translated to functions with one required parameter.
No, two required parameters,
Objects wrote:A property definition with both get and set actually creates two separate functions, which do not share local or static variables or nested functions. As with methods, each function has a hidden parameter named this, and set has a second hidden parameter named value.
This code doesn't make sense,
Code: Select all
x := {}
x.defineProp("prop", {set: (value?) => msgbox()})
x.prop := unset
the parameter you named
value will not hold the
value being assigned, unset or otherwise. It references the object being invoked, in this case
x. If there is a bug here, it's
x.prop := unset, I couldn't find any reference to its meaning in the docs.
Cheers.