diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-04-21 08:41:09 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-04-21 08:41:09 +0000 |
commit | 42e7ea3f1b5343a01e7dcb0a546a153913be72c2 (patch) | |
tree | 290f5b7d1ff924b1517341a59bd4efa5928bab15 /array.c | |
parent | 0a22a40a5422a027da3be1ebe9795e294ddb47cc (diff) | |
download | ruby-42e7ea3f1b5343a01e7dcb0a546a153913be72c2.tar.gz |
ruby 1.1b9_13
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@179 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r-- | array.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -412,6 +412,20 @@ ary_index(ary, val) } static VALUE +ary_rindex(ary, val) + VALUE ary; + VALUE val; +{ + int i = i<RARRAY(ary)->len; + + while (i--) { + if (rb_equal(RARRAY(ary)->ptr[i], val)) + return INT2FIX(i); + } + return Qnil; +} + +static VALUE ary_indexes(argc, argv, ary) int argc; VALUE *argv; @@ -1299,6 +1313,7 @@ Init_Array() rb_define_alias(cArray, "size", "length"); rb_define_method(cArray, "empty?", ary_empty_p, 0); rb_define_method(cArray, "index", ary_index, 1); + rb_define_method(cArray, "rindex", ary_rindex, 1); rb_define_method(cArray, "indexes", ary_indexes, -1); rb_define_method(cArray, "indices", ary_indexes, -1); rb_define_method(cArray, "clone", ary_clone, 0); |