mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 21:49:06 +02:00
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:
parent
c01a5ee85e
commit
c28c20ee88
2 changed files with 12 additions and 4 deletions
10
array.c
10
array.c
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue