Usage of getValue with name of variable is not intuitive
Posted: 24 Jul 2014 11:52
The usage of getValue and removeVariable with the name of a variable in quotes is not intuitive at all.
I don't know how often I already fell into that particular pit...This will always set global_something to true, because getValue expects the name of a variable and not the variable itself.
Even if global_something already exists it will most certainly not contain it's own name, so getValue will always return the given default value...
This, however, will work, please note the single quotes around the first parameter:
If that behaviour cannot be changed for some strange reason getValue or removeVariable should at least throw an exception if the evaluation of the name parameter yields null.
Putting empty names into those functions can't make any sense at all, right?
I don't know how often I already fell into that particular pit...
Code: Select all
global_something = getValue(global_something, true);
Even if global_something already exists it will most certainly not contain it's own name, so getValue will always return the given default value...
This, however, will work, please note the single quotes around the first parameter:
Code: Select all
global_something = getValue('global_something', true);
Putting empty names into those functions can't make any sense at all, right?