You’ll be hard pressed to escape working with hashes in Ruby, but don’t make
using them a painful experience. Here are some helpful tips that I’ve collected
that I would like to share.
slice over a helper method
I see this more often then I care to remember:
defconvert(hash)
{
key:hash[:key],
key2:hash[:key2]
}
end
Hash has this built in and performs the same as above.
hash.slice(:key,:key2)
churning values out into an array
[hash[:key],hash[:key2],hash[:key3]]
values_at will perform this with a little less mess.