The application at hand is pretty basic. I have a sub that wraps around a hash to keep track of some traits for some items, traits which may or may not have a specified value. Example:
if(trait('bob','isAdult')){print trait('bob','age')}One obvious way would be to use defined, as you say. It's a matter of encapsulation; I think it looks nicer if the code that uses this sub doesn't have to worry about that distinction. Another obvious way would be to use two different functions, but again, more visible complexity.
A third would be to use a simple true value like "1", and hope that there's no conflict, but if the user decides to mix values and "non-values" in the same trait, that could go very wrong.
In reply to Re^2: "" but true
by Chuma
in thread "" but true
by Chuma
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |