1 decade ago by vincentpiel
The get / set syntax is very usefull, it works like this :
var tellMe = {
get message() { return this._message;},
set message (val) { this._message=' still no, even if you say '+val; }
_message :"no",
};
alert (tellMe.message); // -- >> "no"
tellMe.message = "yes";
alert (tellMe.message); // -- >> "still no, even if you say yes"
so it is a handy (and not uncommon in other languages) thing.
BUT ... if i use get / set in a ig.Class, for instance when extending an ig.Class,
i get :
alert (tellMeClass.message); // -- >> "no"
tellMeClass.message = "yes";
alert (tellMeClass.message); // -- >> "yes"
so it is broken.
Notice that the getter stills works, but the setter does not, so first time you
write to the property the getter is destroyed.
So right now you might only do readonly properties.
(Rq : i found that link usefull : http://ejohn.org/blog/javascript-getters-and-setters/ )
var tellMe = {
get message() { return this._message;},
set message (val) { this._message=' still no, even if you say '+val; }
_message :"no",
};
alert (tellMe.message); // -- >> "no"
tellMe.message = "yes";
alert (tellMe.message); // -- >> "still no, even if you say yes"
so it is a handy (and not uncommon in other languages) thing.
BUT ... if i use get / set in a ig.Class, for instance when extending an ig.Class,
i get :
alert (tellMeClass.message); // -- >> "no"
tellMeClass.message = "yes";
alert (tellMeClass.message); // -- >> "yes"
so it is broken.
Notice that the getter stills works, but the setter does not, so first time you
write to the property the getter is destroyed.
So right now you might only do readonly properties.
(Rq : i found that link usefull : http://ejohn.org/blog/javascript-getters-and-setters/ )