Fix error message

* array.c (ary_take_first_or_last): expected optional argument.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66190 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2018-12-04 09:16:49 +00:00
parent c01a5ee85e
commit c28c20ee88
2 changed files with 12 additions and 4 deletions

10
array.c
View file

@ -1108,13 +1108,17 @@ enum ary_take_pos_flags
static VALUE
ary_take_first_or_last(int argc, const VALUE *argv, VALUE ary, enum ary_take_pos_flags last)
{
VALUE nv;
long n;
long len;
long offset = 0;
rb_scan_args(argc, argv, "1", &nv);
n = NUM2LONG(nv);
argc = rb_check_arity(argc, 0, 1);
/* the case optional argument is ommited should be handled in
* callers of this function. if another arity case is added,
* this arity check needs to rewrite. */
RUBY_ASSERT_WHEN(TRUE, argc == 1);
n = NUM2LONG(argv[0]);
len = RARRAY_LEN(ary);
if (n > len) {
n = len;