Ruby Issue Tracking System: Issues
https://redmine.ruby-lang.org/
https://redmine.ruby-lang.org/favicon.ico?1711330511
2012-02-21T01:31:02Z
Ruby Issue Tracking System
Redmine
Ruby master - Bug #6053 (Closed): Enumerator#rewind goes to beginning instead of decrementing one...
https://redmine.ruby-lang.org/issues/6053
2012-02-21T01:31:02Z
tyre77 (Chris Maddox)
tyre77@gmail.com
<p>From the ruby docs:<br>
rewind → e<br>
Rewinds the enumeration sequence by one step.</p>
<p>In practice, however, it fully rewinds (either change documentation or have it do what it says. Going back one step is nice though):<br>
irb(main):001:0> a = [1,2,3,4]<br>
=> [1, 2, 3, 4]<br>
irb(main):002:0> b = a.to_enum<br>
=> #<Enumerator: [1, 2, 3, 4]:each><br>
irb(main):007:0> b.next<br>
=> 1<br>
irb(main):008:0> b.next<br>
=> 2<br>
irb(main):009:0> b.next<br>
=> 3<br>
irb(main):010:0> b.rewind<br>
=> #<Enumerator: [1, 2, 3, 4]:each><br>
irb(main):011:0> b.next<br>
=> 1</p>