Skip to content

Expected behavior of comprehensions #323

Discussion options

You must be logged in to vote

Hi there!

Your analysis is correct. There are probably better explanations available in the docs, but this one comes to mind.

When evaluating rule bodies, OPA searches for variable bindings that make all of the expressions true. There may be multiple sets of bindings that make the rule body true.

The same goes for comprehensions — there are two "bindings" in your comprehension where the expression is true, resulting in two items stored in the resulting array.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mingweishih
Comment options

Answer selected by mingweishih
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants