13
10

More than 5 years have passed since last update.

YAMLのブーリアン

Posted at
YAML.load <<EOC
hoge:
  yes: 1
  no: 2
EOC
=> {"hoge"=>{true=>1, false=>2}}
YAML.load <<EOC
hoge:
  on: 1
  off: 2
EOC
=> {"hoge"=>{true=>1, false=>2}}

便利(ぇ

これはYAMLの仕様なので [*1] 仕方ない。例えば以下のように回避できる。

YAML.load <<EOC
hoge:
  "yes": 1
EOC
=> {"hoge"=>{"yes"=>1}}

[*1] Boolean Language-Independent Type for YAML™ Version 1.1

13
10
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
10