public Method

Array.+(p1)

array + other_array    an_array

Concatenation—Returns a new array built by concatenating the two arrays together to produce a third array.

[ 1, 2, 3 ] + [ 4, 5 ]    #=> [ 1, 2, 3, 4, 5 ]

Source Code

/* 
*  call-seq:
*     array + other_array   -> an_array
*
*  Concatenation---Returns a new array built by concatenating the
*  two arrays together to produce a third array.
* 
*     [ 1, 2, 3 ] + [ 4, 5 ]    #=> [ 1, 2, 3, 4, 5 ]
*/

VALUE
rb_ary_plus(x, y)
   VALUE x, y;
{
   VALUE z;
   long len;

   y = to_ary(y);
   len = RARRAY(x)->len + RARRAY(y)->len;
   z = rb_ary_new2(len);
   MEMCPY(RARRAY(z)->ptr, RARRAY(x)->ptr, VALUE, RARRAY(x)->len);
   MEMCPY(RARRAY(z)->ptr + RARRAY(x)->len, RARRAY(y)->ptr, VALUE, RARRAY(y)->len);
   RARRAY(z)->len = len;
   return z;
}
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.