4 ms·
Strings in YAML – To quote or not to quote (2018)
- merlincorey 4y agoI'm surprised in a discussion of when to quote or not quote with YAML the dreaded "yes", "no", "true", "false", "on", and "off" booleans didn't come up. Quoting the article: > In YAML, you can write a string without quotes, if it doesn't have a special meaning. Yeah, about that...
- AceJohnny2 4y agoIndeed the if is doing a lot of work there ;) What parent refers to, YAML's Norway Problem: https://hitchdev.com/strictyaml/why/implicit-typing-removed/ https://hitchdev.com/strictyaml/why/implicit-typing-removed/
- Defletter 4y agoDidn't realise YAML's problems were that extensive, but I have to disagree with the seeming decision to effectively parse everything as strings instead of requiring all strings be quoted.
- AceJohnny2 4y agoit's really a good lesson in "make it human-readable" being at odds with "make it easily parseable"
- deleted 4y ago[deleted]
- deleted 4y ago[deleted]
- emmelaich 4y agoIt is mentioned though ... > Another use case for quotes is when you have a string that would be resolved as a special type. This highly depends on the YAML version and on the Schema in use. Here are some examples where you need quotes: true, false 23 1e3 3.14159 null
- Spivak 4y agoEh, YAML 1.2 fixed this. It's only true/false now. The set of values that are special is pretty sane now. true, false, null, <ints>, <floats>
- mhio 4y agoQuote strings, always.
- deleted 4y ago[deleted]
- behnamoh 4y agoIs this even a question? I double quote ALL strings. In fact, my C background makes me use " in Python too, even though single quote ' is acceptable. Somehow " feels more __stringy__.
- raydiatian 4y ago“You guys’ heads are on backwards”, I said. “How many times have your strings needed to convey some speaker’s voice? How many times have your coded strings needed to convey an object’s possession relationship?” Apostrophe, 3. Double quotes, 0.
- deleted 4y ago[deleted]
- imwillofficial 4y agoFor the love of God, save yourself pain. Always quote.