YAML::Syck::Map.children_with_index has a non-useless mode?

P

Phlip

Ruboids:

I have some dirt-simple YAML, and I need to traverse the object model
returned by YAML.parse().

So if the top-level object is a Map (corresponding naturally to a native
Hash), how do I get the keys and values?

Try this:

map.children_with_index.each do |kid, key|
p kid
p key
end

The 'key's come out healthy Scalars, but the 'kid's are always nil!
Permutations involving map[key] and map.at(key) also return nil, because
that's what

Oh why can't I get non-nil kids from my map?? (Without using map.value[key]
to go down to the Hash - because I don't want to!)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top