Replies: 2 comments
-
@verytable sorry for the slow response here. Lists and structs have a default value of the empty list or struct respectively:
gives:
I think the quote from the spec "Lists can be thought of as structs" is meant to illustrate another way of thinking about lists, but I can see how it is misleading in light of the above. The behaviour of your example:
has changed with respect to |
Beta Was this translation helpful? Give feedback.
-
This discussion has been migrated to cue-lang/cue#914. For more details about CUE's migration to a new home, please see cue-lang/cue#1078. |
Beta Was this translation helpful? Give feedback.
-
General question. Do lists work well with defaults? If they don't I think this should be explicitly mentioned in docs.
My doubts are based on the following quote from docs:
that shows that List has default (*) in it's definition. Also there are no list examples in the "Default values " section of the docs.
Example.
Evaluation of the following code (with cue 0.3.2)
{ arr: [...string] | [] } & {arr: *[] | [...string]}
results in
arr: incomplete value [] | []
However, this
{ arr: [...string]} & {arr: *[] | [...string]}
results in
{ "arr": [] }
The first example also works with cue 0.2.2.
What is the difference between these two snippets?
Beta Was this translation helpful? Give feedback.
All reactions