mirror of
https://github.com/ruby/ruby.git
synced 2025-08-23 04:55:21 +02:00
* array.c (rb_ary_each, rb_ary_each_index, rb_ary_reverse_each,
rb_ary_reject_bang): Calling Array#each, #each_index, #reverse_each, #reject! or #delete_if without a block now returns an enumerator; backported from 1.9. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15938 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6584020a57
commit
343069e16a
2 changed files with 13 additions and 1 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
Wed Apr 9 21:13:05 2008 Akinori MUSHA <knu@iDaemons.org>
|
||||||
|
|
||||||
|
* array.c (rb_ary_each, rb_ary_each_index, rb_ary_reverse_each,
|
||||||
|
rb_ary_reject_bang): Calling Array#each, #each_index,
|
||||||
|
#reverse_each, #reject! or #delete_if without a block now
|
||||||
|
returns an enumerator; backported from 1.9.
|
||||||
|
|
||||||
Wed Apr 9 20:47:16 2008 Akinori MUSHA <knu@iDaemons.org>
|
Wed Apr 9 20:47:16 2008 Akinori MUSHA <knu@iDaemons.org>
|
||||||
|
|
||||||
* array.c (rb_ary_index, rb_ary_index): Array#index and #rindex
|
* array.c (rb_ary_index, rb_ary_index): Array#index and #rindex
|
||||||
|
|
7
array.c
7
array.c
|
@ -1162,6 +1162,7 @@ rb_ary_each(ary)
|
||||||
{
|
{
|
||||||
long i;
|
long i;
|
||||||
|
|
||||||
|
RETURN_ENUMERATOR(ary, 0, 0)
|
||||||
for (i=0; i<RARRAY(ary)->len; i++) {
|
for (i=0; i<RARRAY(ary)->len; i++) {
|
||||||
rb_yield(RARRAY(ary)->ptr[i]);
|
rb_yield(RARRAY(ary)->ptr[i]);
|
||||||
}
|
}
|
||||||
|
@ -1189,6 +1190,7 @@ rb_ary_each_index(ary)
|
||||||
{
|
{
|
||||||
long i;
|
long i;
|
||||||
|
|
||||||
|
RETURN_ENUMERATOR(ary, 0, 0);
|
||||||
for (i=0; i<RARRAY(ary)->len; i++) {
|
for (i=0; i<RARRAY(ary)->len; i++) {
|
||||||
rb_yield(LONG2NUM(i));
|
rb_yield(LONG2NUM(i));
|
||||||
}
|
}
|
||||||
|
@ -1214,8 +1216,10 @@ static VALUE
|
||||||
rb_ary_reverse_each(ary)
|
rb_ary_reverse_each(ary)
|
||||||
VALUE ary;
|
VALUE ary;
|
||||||
{
|
{
|
||||||
long len = RARRAY(ary)->len;
|
long len;
|
||||||
|
|
||||||
|
RETURN_ENUMERATOR(ary, 0, 0);
|
||||||
|
len = RARRAY(ary)->len;
|
||||||
while (len--) {
|
while (len--) {
|
||||||
rb_yield(RARRAY(ary)->ptr[len]);
|
rb_yield(RARRAY(ary)->ptr[len]);
|
||||||
if (RARRAY(ary)->len < len) {
|
if (RARRAY(ary)->len < len) {
|
||||||
|
@ -2033,6 +2037,7 @@ rb_ary_reject_bang(ary)
|
||||||
{
|
{
|
||||||
long i1, i2;
|
long i1, i2;
|
||||||
|
|
||||||
|
RETURN_ENUMERATOR(ary, 0, 0);
|
||||||
rb_ary_modify(ary);
|
rb_ary_modify(ary);
|
||||||
for (i1 = i2 = 0; i1 < RARRAY(ary)->len; i1++) {
|
for (i1 = i2 = 0; i1 < RARRAY(ary)->len; i1++) {
|
||||||
VALUE v = RARRAY(ary)->ptr[i1];
|
VALUE v = RARRAY(ary)->ptr[i1];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue