Hi,
I want to load the following yaml content:
Yellow: 1
Blue: 2
Red: 3
And build two arrays: one for keys, that must be in this order:
[‘Yellow’, ‘Blue’, ‘Red’] and another for values:
[1, 2, 3]
How can I do that?
Thanks
Hi,
I want to load the following yaml content:
Yellow: 1
Blue: 2
Red: 3
And build two arrays: one for keys, that must be in this order:
[‘Yellow’, ‘Blue’, ‘Red’] and another for values:
[1, 2, 3]
How can I do that?
Thanks
Alle Tuesday 04 March 2008, Ranieri T. ha scritto:
[1, 2, 3]
How can I do that?
Thanks
As far as I can tell, you can’t. This is because the notation
key: value
in YAML represents a hash, which is sorted in an arbitrary order. If you
want
to keep the order, the simplest way is to replace the YAML hash with a
nested
list:
I hope this helps
Stefano
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