Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expression building failing with leading numbers in variable name #109

Open
apoorv-28 opened this issue Jul 2, 2020 · 2 comments
Open

Comments

@apoorv-28
Copy link

Expression : 1*2a

Error: Unknown function or variable 'a' at pos 3 in expression '1*2a'

Code:

val map = Map("2a" -> 0.1)
val expressionBuilder = new ExpressionBuilder("1*2a")
  .variables(map.keys.toList: _*)
  .build

Is this not supported or is it a probable bug?

@seyfahni
Copy link

seyfahni commented Jul 3, 2020

It is currently not supported: https://www.objecthunter.net/exp4j/#Variable_declaration

Variable names must start with a letter or the underscore

@Kris-kun
Copy link

Well, propably because someting like "2a" is mathematically correct when "a" is a variable ("2a" = "2*a"). So if you had a variable "a" and "2a", the expression couldn't be compiled because it doesn't know which to use ("2a" as a variable or two times "a").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants