Method: String#join

Defined in:
lib/extra/string.rb

#join(*arr) ⇒ Object

The ugly and well… unneeded Pythonic join method. Thanks to manveru for pointing out the interesting way of using array expansion with a combination of Array#flatten to support multiple arguments.

Example: ', '.join([1, 2, 3]) #=> "1, 2, 3"

Returns: The joined string.



39
40
41
# File 'lib/extra/string.rb', line 39

def join(*arr)
  arr.flatten.join(self)
end