...

Text file src/cuelang.org/go/doc/tutorial/basics/4_references/10_scopes.txtar

Documentation: cuelang.org/go/doc/tutorial/basics/4_references

     1exec cue eval scopes.cue
     2cmp stdout expect-stdout-cue
     3
     4-- frontmatter.toml --
     5title = "References and Scopes"
     6description = ""
     7
     8-- text.md --
     9A reference refers to the value of the field defined within the nearest
    10enclosing scope.
    11
    12If no field matches the reference within the file, it may match a top-level
    13field defined in any other file of the same package.
    14
    15If there is still no match, it may match a predefined value.
    16
    17-- scopes.cue --
    18v: 1
    19a: {
    20    v: 2
    21    b: v // matches the inner v
    22}
    23a: {
    24    c: v // matches the top-level v
    25}
    26b: v
    27
    28-- expect-stdout-cue --
    29v: 1
    30a: {
    31    v: 2
    32    c: 1
    33    b: 2
    34}
    35b: 1

View as plain text