Hi all
This snippet:
properties = [:a, :b, :c]
counter = (1..properties.length).each
attributes = properties.inject({}) { |attribs, property|
attribs[property] = counter.next
attribs
}
puts attributes
produces this output:
{:a=>1, :b=>2, :c=>3}
But I'm sure you can do much better in Ruby 1.9. Anyone know how and wanna
show me? :)
Cheers
Ash
--
http://www.patchspace.co.uk/
http://www.linkedin.com/in/ashleymoran
--
You received this message because you are subscribed to the Google Groups
"NWRUG" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nwrug-members?hl=en.