#!/usr/bin/ruby1.8
require 'yaml'
a = { "b" => "c", "d" => nil, "e" => "f" }
puts a.to_yaml
result:
b: c
d:
e: f
but must be:
b: c
d: ~
e: f
#!/usr/bin/ruby1.8
require 'yaml'
a = { "b" => "c", "d" => nil, "e" => "f" }
puts a.to_yaml
result:
b: c
d:
e: f
but must be:
b: c
d: ~
e: f
On 11/22/06, Vladimir M. [email protected] wrote:
b: c
d:
e: fbut must be:
b: c
d: ~
e: f
Not a bug.
According to [1] the canonical representation for !!null is indeed
‘~’, but the empty string (as well as the tokens ‘null’, ‘Null’ and
‘NULL’) are also acceptable representations. And we needn’t worry
about confusion with the empty string since the empty string must be
represented with quotation marks, e.g.:
d: “”
There may be an argument that the YAML serialization of Ruby’s nil
should be ‘~’ instead of an empty string, but it is not the case
that it must be so.
Jacob F.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs