github.com/solo-io/cue@v0.4.7/doc/tutorial/basics/2_types/56_optional.txt (about)

     1  cue eval -c structs.cue
     2  cmp stdout expect-stdout-cue
     3  
     4  -- frontmatter.toml --
     5  title = "Structs"
     6  description = ""
     7  
     8  -- text.md --
     9  Struct is the most important composite type in CUE.
    10  Its members are called fields.
    11  
    12  A struct field may be optional.
    13  One can use an optional field to indicate what the type should be if it were
    14  specified.
    15  A regular (or required) field, on the other hand, must be made concrete
    16  for a configuration to be converted to, say, JSON.
    17  
    18  It is okay for an optional field to be bottom (`_|_`).
    19  This just means that field may not be specified.
    20  
    21  -- structs.cue --
    22  #a: {
    23      foo?: int
    24      bar?: string
    25      baz?: string
    26  }
    27  b: #a & {
    28      foo:  3
    29      baz?: 2  // baz?: _|_
    30  }
    31  
    32  -- expect-stdout-cue --
    33  b: {
    34      foo: 3
    35  }