Is there a way to implode an array in Ruby to combine all elements into one string?
Example Array:
@arr = ['<p>Hello World</p>', '<p>This is a test</p>']
Example Output:
<p>Hello World</p> <p>This is a test</p>
Thanks in advance!
Is there a way to implode an array in Ruby to combine all elements into one string?
Example Array:
@arr = ['<p>Hello World</p>', '<p>This is a test</p>']
Example Output:
<p>Hello World</p> <p>This is a test</p>
Thanks in advance!
Use the Array#join
method (the argument to join
is what to insert between the strings - in this case a space):
@arr.join(" ")