diff options
| -rw-r--r-- | include/mruby/array.h | 1 | ||||
| -rw-r--r-- | src/array.c | 4 |
2 files changed, 5 insertions, 0 deletions
diff --git a/include/mruby/array.h b/include/mruby/array.h index e2dd9bb1c..fd4094a02 100644 --- a/include/mruby/array.h +++ b/include/mruby/array.h @@ -239,6 +239,7 @@ MRB_API mrb_value mrb_ary_entry(mrb_value ary, mrb_int offset); * @param head Beginning position of a replacement subsequence. * @param len Length of a replacement subsequence. * @param rpl The array of replacement elements. + * It is possible to pass `mrb_undef_value()` instead of an empty array. * @return The receiver array. */ MRB_API mrb_value mrb_ary_splice(mrb_state *mrb, mrb_value self, mrb_int head, mrb_int len, mrb_value rpl); diff --git a/src/array.c b/src/array.c index 8547cfff4..6e73bcd8e 100644 --- a/src/array.c +++ b/src/array.c @@ -732,6 +732,10 @@ mrb_ary_splice(mrb_state *mrb, mrb_value ary, mrb_int head, mrb_int len, mrb_val argv = ARY_PTR(r); } } + else if (mrb_undef_p(rpl)) { + argc = 0; + argv = NULL; + } else { argc = 1; argv = &rpl; |
