setStringVariable method
Sets a variable value.
variable
- The variable to set.
value
- The variable value.
Returns the expression, allows to chain methods.
Implementation
Expression setStringVariable(String variable, String value) {
if (isNumber(value)) {
variables[variable] = createLazyNumber(Decimal.parse(value));
} else if (value.toLowerCase() == "null") {
variables[variable] = null;
} else {
final String expStr = value;
variables[variable] = LazyNumberImpl(eval: () {
Expression innerE = Expression(expStr);
innerE.variables = variables;
innerE.functions = functions;
innerE.operators = operators;
Decimal? val = innerE.eval();
return val;
}, getString: () {
return expStr;
});
_rpn = null;
}
return this;
}