Skip to content

Instantly share code, notes, and snippets.

@ymendel
Created December 17, 2009 00:45
Show Gist options
  • Select an option

  • Save ymendel/258383 to your computer and use it in GitHub Desktop.

Select an option

Save ymendel/258383 to your computer and use it in GitHub Desktop.
$ irb
irb(main):001:0> things = %w[one two three]
=> ["one", "two", "three"]
irb(main):002:0> things.inject([]) do |result, item|
irb(main):003:1* result + [ [item, "#{item} fish"], [item*2, "#{item} doubled"]]
irb(main):004:1> end
=> [["one", "one fish"], ["oneone", "one doubled"], ["two", "two fish"], ["twotwo", "two doubled"], ["three", "three fish"], ["threethree", "three doubled"]]
irb(main):005:0>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment