YAML

Table of Contents

Anchors and References

base: &base
  apple: 0
  banana: 1

foo:
  <<: *base
  apple: 1  # overrides
  orange: 2

But this mechanism just works as replacements. You shouldn't expect yaml to handle nested structures.

base: &base
  a: 10
  b:
    c: 10

foo:
  <<: *base
  b:
    d: 20

# foo is equivalent to:
foo:
  a: 10
  b:      # overrideen, not inherited
    d: 20

If you want to make an effect like inheritance:

base: &base
  a: 10
  b: &b
    c: 10
foo:
  <<: *base
  b:
    <<: *b
    d: 20

# foo is now equivalent to:
foo:
  a: 10
  b:
    c: 10
    d: 20