Skip to content

Instantly share code, notes, and snippets.

Created Jan 24, 2011
What would you like to do?
an example of inject with some Johnny Cash flavor
places = %w( Reno Chicago Fargo Minnesota Buffalo Toronto Winslow Sarasota
Wichita Tulsa Ottawa Oklahoma Tampa Panama Mattawa La Paloma
Bangor Baltimore Salvador Amarillo Tocapillo Baranquilla and
puts places.inject("I've been to: ") { |result, place| "#{result}#{place}, " } + "I'm a killer"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment