APIdock / Ruby
/
method

join

v2_5_5 - 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 the given separator. If the separator is nil, it uses current ,ドル. If both the separator and ,ドル are nil, it uses an empty string.

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

For nested arrays, join is applied recursively:

[ "a", [1, 2, [:x, :y]], "b" ].join ("-") #=> "a-1-2-x-y-b"
static VALUE
rb_ary_join_m(int argc, VALUE *argv, VALUE ary)
{
 VALUE sep;
 rb_scan_args(argc, argv, "01", &sep);
 if (NIL_P(sep)) sep = rb_output_fs;
 return rb_ary_join(ary, sep);
}

AltStyle によって変換されたページ (->オリジナル) /