Class GetOr
java.lang.Object
com.singularsys.jep.functions.PostfixMathCommand
com.singularsys.jep.functions.NaryFunction
com.singularsys.jep.misc.dictionary.GetOr
- All Implemented Interfaces:
PostfixMathCommandI,Serializable
Gets the value associated with a key, or a default value.
The function returns either the value associated with the key,
supplied default value.
If no value is associate with the key then
map = {'x':2, 'y':3};
getOr(map, 'x', -1);
nullValue is returned.- Since:
- Jep 4.1
- See Also:
-
Field Summary
FieldsFields inherited from class com.singularsys.jep.functions.PostfixMathCommand
curNumberOfParameters, description, name, NaN, numberOfParameters -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class com.singularsys.jep.functions.NaryFunction
runMethods inherited from class com.singularsys.jep.functions.PostfixMathCommand
asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, asType, checkNumberOfParameters, getDescription, getDescription, getDescriptionWithType, getName, getNumberOfParameters, setCurNumberOfParameters, setDescription, setName, toString, toString
-
Field Details
-
nullValue
-
-
Constructor Details
-
GetOr
Constructor- Parameters:
nullValue- , value returned when a key has no value.
-
GetOr
public GetOr()
-
-
Method Details
-
eval
Description copied from class:NaryFunctionEvaluate the function- Specified by:
evalin classNaryFunction- Parameters:
args- arguments to the function- Returns:
- value returned by the function
- Throws:
EvaluationException- if the calculation cannot be performed
-
eval
-
eval
- Throws:
EvaluationException
-
equals
Test if key equals k. Default implementation useskey.equals(k)- Parameters:
key- key to testk- key to test- Returns:
- true if parameters are equal
- Throws:
EvaluationException
-