team-genny / genny

0 stars 1 forks source link

Add support for binary operators (e.g. +, -, *, /) in formulas #5

Open fergcb opened 4 months ago

fergcb commented 4 months ago

The formula parser and compiler should be enhanced to include support for binary operator expressions, e.g. 5 * 2 or "Hello" + " " + "World".

We should support at least the following operators, with the ability add more if needed:

Operator Description
+ Add two numbers or concatenate two strings.
- Subtract a number from another.
* Multiply two numbers together.
/ Divide a number by another.
% Compute a number modulo another (remainder of integer division)
&& Compute the logical AND of two variables¹.
\|\| Computer the logical OR of two variables¹.

¹ - 0, "", null and false should be considered falsy for logical operations.

Nice to Have

Here are some optional ways to improve this feature:

If these optional features are not added, new issues should be created to deal with them in the future.