10 YAML

YAML is my favorite configuration language

10.1 basics

用相同数目的空格(我推荐 4个)缩进元素,来表示层级关系。

age: 27
men: [John, Bill]
women:
  - Mary
  - Susan
websites:
  YAML: yaml.org 

10.2 yes or no, that is a question

这一节是我无意中发现的,当时在纠结到底应该写 yes|no 还是 true|false(最后我选择了前者,因为 YAML 强调 human-readable)。

yes: yes
no: no

means

$`TRUE`
[1] TRUE

$`FALSE`
[1] FALSE

You should add quotes to avoid being interpreted as T or F

'yes': yes
'no': 'no'

means

$yes
[1] TRUE

$no
[1] "no"

There’s actually a long list of reserved words with this behavior:

y|Y|yes|Yes|YES|n|N|no|No|NO
|true|True|TRUE|false|False|FALSE
|on|On|ON|off|Off|OFF

Wa, the world is so nice!