From 6125313d69c158b423d1f4aff2e206cfd43a036a Mon Sep 17 00:00:00 2001 From: matz Date: Mon, 2 Jun 2003 04:49:46 +0000 Subject: * array.c (push_values_at): Array#values_at should work with ranges too. * range.c (rb_range_beg_len): length calculation was wrong. * eval.c (rb_call): should set T_ICLASS in the frame->last_class. [ruby-core:01110] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3899 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- array.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'array.c') diff --git a/array.c b/array.c index 7359c05060..e0b5af8dce 100644 --- a/array.c +++ b/array.c @@ -1179,6 +1179,31 @@ rb_ary_collect_bang(ary) return ary; } +static void +push_values_at(result, ary, arg) + VALUE result, ary, arg; +{ + long beg, len, i; + + if (FIXNUM_P(arg)) { + rb_ary_push(result, rb_ary_entry(ary, FIX2LONG(arg))); + return; + } + /* check if idx is Range */ + switch (rb_range_beg_len(arg, &beg, &len, RARRAY(ary)->len, 0)) { + case Qfalse: + break; + case Qnil: + return; + default: + for (i=0; i