Skip to content

Instantly share code, notes, and snippets.

@tundal45
Created Jan 24, 2011
Embed
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
Perdilla)
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