Posted about 6 years ago. Visible to the public.

YAML: Keys like "yes" or "no" evaluate to true and false

If you parse this Yaml ...

Copy
yes: 'Totally' no: 'Nope'

... you get this Ruby hash:

Copy
{ true: 'Totally', false: 'Nope' }

In order to use the strings 'yes' and 'no' as keys, you need to wrap them with quotes:

Copy
'yes': 'Totally' 'no': 'Nope'

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

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

I'm sorry.

Once an application no longer requires constant development, it needs periodic maintenance for stable and secure operation. makandra offers monthly maintenance contracts that let you focus on your business while we make sure the lights stay on.

Owner of this card:

Avatar
Henning Koch
Last edit:
about 6 years ago
Keywords:
rails, i18n, localization
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Henning Koch to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more