You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Change
It took several passes over the documentation and some experimentation to realize that a basic "if" statement is indeed easy to write in CEL simply using logical operators. Given that CEL is a golang project and has roots in the kubernetes community as well, clarifying that the lack of an "if" statement does not mean it is unable to perform this type of logic would be ideal.
Example
CEL does not have an "if" statement, however, similar decision making flows are trivial to perform using its built-in logical operators. For example:
@benjaminapetersen I think this is a good example to include in the github.com/google/cel-spec
The ternary operator isn't quite an if statement since a classic if statement doesn't guarantee a return value; however, you can mimic if-else and if-elseif-... flows this way.
TristonianJones
changed the title
Improve documentation/examples to make it more obvious that logical operators replace constructs like "if" statements
Provide examples of the conditional operator
Mar 9, 2023
Change
It took several passes over the documentation and some experimentation to realize that a basic "if" statement is indeed easy to write in CEL simply using logical operators. Given that CEL is a golang project and has roots in the kubernetes community as well, clarifying that the lack of an "if" statement does not mean it is unable to perform this type of logic would be ideal.
Example
CEL does not have an "if" statement, however, similar decision making flows are trivial to perform using its built-in logical operators. For example:
Understanding that CEL can perform simple conditional logic and return one value or another was not immediately obvious.
Alternatives considered
Briefly list alternative designs, or an example of the functionality to be replaced.
The text was updated successfully, but these errors were encountered: