-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Serialize nil as ~
in YAML
#6138
Conversation
But why?
Crystal behaves like Ruby. |
If you want, maybe that can be a configuration of a |
IMO Also, I believe it's not a big trade off in terms of size - just 1 character more for bit of clarity. |
Maybe rename this to "Serialize nil as Example in description would also help |
This issue is about personal taste. No solution is better than the other. My taste follows @asterite here. I prefer having nothing than |
Just to clarify (as I opened the related issue), that issue was mainly due to my lack of knowledge on how null could be represented in YAML. Coming from Python's PyYAML, I was used to seeing the word I personally believe the current behaviour is the most appropriate. Not only does it follow Ruby's style but also printing any Users who want different behaviour can very easily patch this as follows: struct Nil
def to_yaml(yaml : YAML::Nodes::Builder)
yaml.scalar "~"
end
end |
While I initially brought up the suggestions to use The only (minor) case where a change might perhaps be useful is |
I would prefer |
I believe we'll stick with the current behavior. Closing. |
Result with following code:
before:
--- foo:
after:
Refs #6137