method

join

v1_9_2_180 - Show latest stable - Class: Array
join(p1 = v1)
public

Returns a string created by converting each element of the array to a string, separated by sep.

[ "a", "b", "c" ].join        #=> "abc"
[ "a", "b", "c" ].join("-")   #=> "a-b-c"

1Note

Usage

newdark ยท Jan 4, 2012

I use this in views when I need to join a array of objects from a sql request here is a basic version of what I mean.

==== Code example

<%= @blogs.map{ |blog| blog.comment }.join(" | ") %>