Skip to content

Restriction on special characters in variable names? #383

Answered by uklimaschewski
RedPxnda asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, variable names must start with a letter or an underscore. So the underscore is the only special character that is allowed for a variable:

    Expression expression = new Expression("_a + _b");
    expression.with("_a", 2).and("_b", 3).evaluate();

With some changes, a feature could be added to allow configuring additional characters, e.g. the $ character is a common special character denoting variables, e.g. this could look like this:

    Expression expression = new Expression("$a + $b");
    expression.with("$a", 2).and("$b", 3).evaluate();

If you want to contribute, then you are welcome. :-)

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by RedPxnda
Comment options

You must be logged in to vote
1 reply
@uklimaschewski
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants