...

Text file src/cuelang.org/go/doc/tutorial/basics/4_references/30_aliases.txtar

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

     1exec cue eval alias.cue
     2cmp stdout expect-stdout-cue
     3
     4-- frontmatter.toml --
     5title = "Aliases"
     6description = ""
     7
     8-- text.md --
     9An alias defines a local macro.
    10
    11A typical use case is to provide access to a shadowed field.
    12
    13Aliases are not members of a struct. They can be referred to only within the
    14struct, and they do not appear in the output.
    15
    16-- alias.cue --
    17let A = a  // A is an alias for a
    18a: {
    19    d: 3
    20}
    21b: {
    22    a: {
    23        // A provides access to the outer "a" which would
    24        // otherwise be hidden by the inner one.
    25        c: A.d
    26    }
    27}
    28
    29-- expect-stdout-cue --
    30a: {
    31    d: 3
    32}
    33b: {
    34    a: {
    35        c: 3
    36    }
    37}

View as plain text