Skip to content

Commit

Permalink
* Fixed a bug in IListOps.ReverseIndex (core/array/rindex specs were …
Browse files Browse the repository at this point in the history
…passing, this bug was triggered under certain conditions different from the ones defined in the specs)

* Fixed ArrayOps.ReverseEach to make it not fail when elemens in the array are removed from inside a block.
  • Loading branch information
nrk committed Apr 23, 2009
1 parent 722dd4d commit d2b18f5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.

This file was deleted.

Expand Up @@ -558,11 +558,15 @@ private sealed class BreakException : Exception {
throw RubyExceptions.NoBlockGiven();
}

for (int i = self.Count - 1; i >= 0; --i) {
for (int originalSize = self.Count, i = originalSize - 1; i >= 0; i--) {
object result;
if (block.Yield(self[i], out result)) {
return result;
}
if (self.Count < originalSize) {
i = originalSize - i - 1 + self.Count;
originalSize = self.Count;
}
}
return self;
}
Expand Down
Expand Up @@ -1040,6 +1040,7 @@ public static class IListOps {
}
if (self.Count < originalSize) {
i = originalSize - i - 1 + self.Count;
originalSize = self.Count;
}
}
return null;
Expand Down

0 comments on commit d2b18f5

Please sign in to comment.