why — (3 dashes/hyphen) in yaml file?

As you already found out, the three dashes --- are used to signal the start of a document, i.e.:

  1. To signal the document start after directives, i.e., %YAML or %TAG lines according to the current spec. For example:

    %YAML 1.2
    %TAG !foo! !foo-types/
    ---
    myKey: myValue
    
  2. To signal the document start when you have multiple yaml documents in the same stream, e.g., a yaml file:

    doc 1
    ---
    doc 2
    

    If doc 2 has some preceding directives, then we have to use three dots ... to indicate the end of doc 1 (and the start of potential directives preceding doc 2) to the parser. For example:

    doc 1
    ...
    %TAG !bar! !bar-types/
    ---
    doc 2
    

The spec is good for yaml parser implementers. However, I find this article easier to read from a user perspective.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)