rubinius/rubinius — pull request #1345 by jtdowney (2011-10-23 13:38:15+00:00)
Title: Implemented Enumerator#peek for 1.9 and fixed a failure for Enumerator#next

### Implemented Enumerator#peek for 1.9

I added #peek to Enumerator in 1.9 which uses a new ivar array called @lookahead. When call it will either use the value in this array or fetch and append a new value from #next. The #next will always check the @lookahead first before generating a new value. This is very similar to how CRuby implements it. @lookahead will only ever have 0 or 1 values. There was a need for a sentinel value of some kind and this allows for a case where #next returns nil.

### Fixed a failure for Enumerator#next

Since I was already separating out the #next implementations, I fixed a failure on 1.9 by removing the call to `@generator.rewind`.