Replies: 8 comments 6 replies
-
As far as I know, Expr only has the ternary statement:
It's in the Operators. |
Beta Was this translation helpful? Give feedback.
-
Yeap. But I do want to implement if statements as well. |
Beta Was this translation helpful? Give feedback.
-
If it could support control flow and custom functions, that would be great. |
Beta Was this translation helpful? Give feedback.
-
maybe we can implement a simple "pattern matching" first?
or
something like aboves is really help |
Beta Was this translation helpful? Give feedback.
-
BTW: currently I use |
Beta Was this translation helpful? Give feedback.
-
Would greatly benefit control flow as well. Either switch case or if/else are good options for my use-cases. I can work around with ternary however, just less practical. |
Beta Was this translation helpful? Give feedback.
-
@antonmedv Any plans on having if-else in near future? It's easier for business folks as well to use |
Beta Was this translation helpful? Give feedback.
-
I'm facing a scenario where if-else proves very helpful, consider this script: if input1 != "" {
return input1
}
b := calculateB(input2);
c := calculateC();
return getResult(b, c); To do this in go expr, I'm currently planning to write this: let b = input1 == "" ? calculateB(input2) : nil;
let c = input1 == "" ? calculateC() : nil;
input1 != "" ? input1 : getResult(b, c) It would be so much nicer if the expression language has a "return" keyword, or a rust-like if-else expression: if input1 != "" {
input1
} else {
let b = calculateB(input2);
let c = calculateC();
getResult(b, c)
} I would say this is easier to read. |
Beta Was this translation helpful? Give feedback.
-
Hey, good day am trying to integrate this into a project as a middleware for the project, I predicted the script is gonna get a little complex, is there a way to have if statements or if-else, I can’t find any documentation or issues about this.
Thanks
Beta Was this translation helpful? Give feedback.
All reactions