Devin Mullins
12/12/2006 2:21:00 PM
Phlip wrote:
> Rubistas:
Ooh! I approve.
Err... you might wanna ask _why directly, or hop into the source. I got
lost at the :seq part -- isn't that a Mapping, not a Sequence?
And FWIW, I got a, i from me_key.value when I ran it. So... order bad. I
think if you care about order -- now's too late in the game.
irb(main):021:0* y.instance_variables.map {|f| [f,
y.instance_variable_get(f)] }
=> [["@style", nil], ["@value",
{#<YAML::Syck::Scalar:0x2e0f43c>=>#<YAML::Syck::
Scalar:0x2e0f48c>,
#<YAML::Syck::Scalar:0x2e0f39c>=>#<YAML::Syck::Scalar:0x2e0f3
ec>}], ["@type_id", nil], ["@kind", :seq]]
Nothing about order there.
(If you have control over the YAML, don't use a mapping - the spec says
order doesn't matter for mappings. A technique I use a lot is a list of
singleton mappings:
- Foo: bar
- Fish: bileff
...)
Devin
> Here's a complete working sample illustrating the issue in YAML::Syck, or
> its documentation:
>
> require 'yaml'
>
> y = YAML.parse("i: b\na: sequence")
> p y.kind # <-- :seq
> ...