Archived
This forum has been archived. Please start a new discussion on GitHub.
return value of getPropertyAsInt
n2503v
in Help Center
The Ice reference manual says:
"getPropertyAsInt
int getPropertyAsInt(string key);
Get a property as an integer. If the property does not exist, 0 is returned."
Is there a way then to differentiate between the following two cases:
1) The property was specified with value 0
2) The property was not specified
thanks, alex
"getPropertyAsInt
int getPropertyAsInt(string key);
Get a property as an integer. If the property does not exist, 0 is returned."
Is there a way then to differentiate between the following two cases:
1) The property was specified with value 0
2) The property was not specified
thanks, alex
0
Comments
-
In general, I would recommend to avoid designs that need to distinguish between a property not being set, and a property being set to the default value that is returned by getProperty() and getPropertyAsInt() for a property that doesn't exist.
The situation is analogous to shell environment variables. You can't tell the difference between a variable that isn't set and a variable that is set to the empty string.
You will probably find that your code becomes cleaner and easier to maintain if you define semantics for properties such that the default value (empty string or zero) is what takes effect when a property is not set. That way, there is no need to distinguish between an unset property and one that's set to the default.
Cheers,
Michi.0
