GitHub

Original file line numberDiff line numberDiff line change

@@ -581,14 +581,16 @@ mrb_ary_shift(mrb_state *mrb, mrb_value self)

581581

static mrb_value

582582

mrb_ary_shift_m(mrb_state *mrb, mrb_value self)

583583

{

584-

struct RArray *a = mrb_ary_ptr(self);

585-

mrb_int len = ARY_LEN(a);

586584

mrb_int n;

587-

mrb_value val;

588585
589586

if (mrb_get_args(mrb, "|i", &n) == 0) {

590587

return mrb_ary_shift(mrb, self);

591-

};

588+

}

589+
590+

struct RArray *a = mrb_ary_ptr(self);

591+

mrb_int len = ARY_LEN(a);

592+

mrb_value val;

593+
592594

ary_modify_check(mrb, a);

593595

if (len == 0 || n == 0) return mrb_ary_new(mrb);

594596

if (n < 0) mrb_raise(mrb, E_ARGUMENT_ERROR, "negative array shift");

Read the original on github.com ↗