using defaults to solve disjunction #3444
-
I was hoping not setting a field could solve a disjunction, given the following:
eval'ing gives:
So far this as expected, however let's add one line to the
I would expect eval'ing this would yield the same answer, as
Am I misunderstanding cue's model in this case? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This is how I would typically write what you want to do, by having the default on the disjunction between the two definitions: https://cuelang.org/play/?id=OVi9f4ylQBz#w=function&i=cue&f=eval&o=cue As for why your original example isn't working as you might think, I'm actually not sure. Here is a simpler example showing an ambiguous result in a similar way:
Interestingly enough, if I drop all |
Beta Was this translation helpful? Give feedback.
This is how I would typically write what you want to do, by having the default on the disjunction between the two definitions: https://cuelang.org/play/?id=OVi9f4ylQBz#w=function&i=cue&f=eval&o=cue
As for why your original example isn't working as you might think, I'm actually not sure. Here is a simpler example showing an ambiguous result in a similar way:
Interestingly enough, if I drop all
f:
fields, then the output is unambiguously1
. The ambiguity only appears with the nesting of a struct field.