Skip to content

Instantly share code, notes, and snippets.

@floere
Created March 17, 2010 21:35
Show Gist options
  • Save floere/335736 to your computer and use it in GitHub Desktop.
Save floere/335736 to your computer and use it in GitHub Desktop.
class Array
# Note: Could also be called ary_join.
#
def real_join element
combined = [element]*(size-1)
zip(combined).flatten.compact
end
end
p [1,2,3,4].real_join 'and' #=> [1, 'and', 2, 'and', 3, 'and', 4]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment