Feature #12333 » multi_concat_prepend.patch
array.c | ||
---|---|---|
/*
|
||
* call-seq:
|
||
* ary.concat(other_ary) -> ary
|
||
* ary.concat(other_ary1, other_ary2,...) -> ary
|
||
*
|
||
* Appends the elements of +other_ary+ to +self+.
|
||
* Appends the elements of +other_ary+s to +self+.
|
||
*
|
||
* [ "a", "b" ].concat( ["c", "d"] ) #=> [ "a", "b", "c", "d" ]
|
||
* [ "a" ].concat( ["b"], ["c", "d"] ) #=> [ "a", "b", "c", "d" ]
|
||
* [ "a" ].concat #=> [ "a" ]
|
||
*
|
||
* a = [ 1, 2, 3 ]
|
||
* a.concat( [ 4, 5 ] )
|
||
* a #=> [ 1, 2, 3, 4, 5 ]
|
||
*
|
||
* a = [ 1, 2 ]
|
||
* a.concat(a, a) #=> [1, 2, 1, 2, 1, 2]
|
||
*
|
||
* See also Array#+.
|
||
*/
|
||
... | ... | |
return x;
|
||
}
|
||
static VALUE
|
||
rb_ary_concat_m(int argc, VALUE *argv, VALUE ary)
|
||
{
|
||
for (int i = 0; i < argc; i++)
|
||
rb_ary_concat(ary, argv[i]);
|
||
return ary;
|
||
}
|
||
/*
|
||
* call-seq:
|
||
... | ... | |
rb_define_method(rb_cArray, "fetch", rb_ary_fetch, -1);
|
||
rb_define_method(rb_cArray, "first", rb_ary_first, -1);
|
||
rb_define_method(rb_cArray, "last", rb_ary_last, -1);
|
||
rb_define_method(rb_cArray, "concat", rb_ary_concat, 1);
|
||
rb_define_method(rb_cArray, "concat", rb_ary_concat_m, -1);
|
||
rb_define_method(rb_cArray, "<<", rb_ary_push, 1);
|
||
rb_define_method(rb_cArray, "push", rb_ary_push_m, -1);
|
||
rb_define_method(rb_cArray, "pop", rb_ary_pop_m, -1);
|
string.c | ||
---|---|---|
return str1;
|
||
}
|
||
static VALUE
|
||
rb_str_concat_m(int argc, VALUE *argv, VALUE ary)
|
||
{
|
||
for (int i = 0; i < argc; i++)
|
||
rb_str_concat(ary, argv[i]);
|
||
return ary;
|
||
}
|
||
/*
|
||
* call-seq:
|
||
* str.prepend(other_str) -> str
|
||
... | ... | |
return str;
|
||
}
|
||
static VALUE
|
||
rb_str_prepend_m(int argc, VALUE *argv, VALUE ary)
|
||
{
|
||
for (int i = argc-1; i >= 0; i--)
|
||
rb_str_prepend(ary, argv[i]);
|
||
return ary;
|
||
}
|
||
st_index_t
|
||
rb_str_hash(VALUE str)
|
||
{
|
||
... | ... | |
rb_define_method(rb_cString, "codepoints", rb_str_codepoints, 0);
|
||
rb_define_method(rb_cString, "reverse", rb_str_reverse, 0);
|
||
rb_define_method(rb_cString, "reverse!", rb_str_reverse_bang, 0);
|
||
rb_define_method(rb_cString, "concat", rb_str_concat, 1);
|
||
rb_define_method(rb_cString, "concat", rb_str_concat_m, -1);
|
||
rb_define_method(rb_cString, "<<", rb_str_concat, 1);
|
||
rb_define_method(rb_cString, "prepend", rb_str_prepend, 1);
|
||
rb_define_method(rb_cString, "prepend", rb_str_prepend_m, -1);
|
||
rb_define_method(rb_cString, "crypt", rb_str_crypt, 1);
|
||
rb_define_method(rb_cString, "intern", rb_str_intern, 0); /* in symbol.c */
|
||
rb_define_method(rb_cString, "to_sym", rb_str_intern, 0); /* in symbol.c */
|