ezylang / EvalEx

EvalEx is a handy expression evaluator for Java, that allows to evaluate simple mathematical and boolean expressions.
https://ezylang.github.io/EvalEx/
Apache License 2.0
979 stars 266 forks source link

Add new function SWITCH #469

Closed oswaldobapvicjr closed 4 months ago

oswaldobapvicjr commented 4 months ago

This PR adds a new function SWITCH, to avoid too many IFs in some situations. The function was inspired by Microsoft Excel.

Syntax

SWITCH(expression, value1, result1, [value2-N, result2-N, ...], [default]

Examples

Expression Result
SWITCH(1, 1, "Sunday", 2, "Monday", 3, "Tuesday") "Sunday"
SWITCH(2, 1, "Sunday", 2, "Monday", 3, "Tuesday") "Monday"
SWITCH(4, 1, "Sunday", 2, "Monday", 3, "Tuesday", "No match") "No match"
sonarcloud[bot] commented 4 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

uklimaschewski commented 4 months ago

Thank you very much!