diff --git a/src/array.c b/src/array.c index 8f2b04d20..a3460c516 100644 --- a/src/array.c +++ b/src/array.c @@ -339,13 +339,29 @@ mrb_ary_concat(mrb_state *mrb, mrb_value self, mrb_value other) ary_concat(mrb, mrb_ary_ptr(self), a2); } +/* + * call-seq: + * array.concat(*other_arrays) -> self + * + * Adds to +array+ all elements from each \Array in +other_arrays+; returns +self+: + * + * a = [0, 1] + * a.concat([2, 3], [4, 5]) # => [0, 1, 2, 3, 4, 5] + */ + static mrb_value mrb_ary_concat_m(mrb_state *mrb, mrb_value self) { - mrb_value ary; + mrb_value *args; + mrb_int len; - mrb_get_args(mrb, "A", &ary); - mrb_ary_concat(mrb, self, ary); + mrb_get_args(mrb, "*!", &args, &len); + for (int i=0; i self + * + * Prepends the given +objects+ to +self+: + * + * a = [:foo, 'bar', 2] + * a.unshift(:bam, :bat) # => [:bam, :bat, :foo, "bar", 2] + * + * Array#prepend is an alias for Array#unshift. + * + * Related: #push, #pop, #shift. + */ + static mrb_value mrb_ary_unshift_m(mrb_state *mrb, mrb_value self) {