Add ability to clear variables in expression #53
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
I just wanted to contribute a very simple change. I wanted to provide the client side to be able to clear the variables set or if a map is passed in to clear the old state.
I have a process that cycles through a series of expressions against different maps with different variables and values.
eg:
expressions = {
expression 1: a + b
expression 2: x - y
}
I have a list of maps with different values:
maps = {
map1: a->1, b->2,
map2: x>5, y->2
}
expression1.setVariables(map1);
expression1.validate(true); will return a true, which is correct!
If immediately after I do expession1.setVariables(map2) this will also return a true, which is incorrect as map2 has variables x and y and not a and b. It returns true because the expression has state with regards to the variables.
For the reason I mentioned above I suggest a clearing of the data. I hope you find this contribution of some benefit to you.
Thanks,
Sajith