Bug #6053
closedEnumerator#rewind goes to beginning instead of decrementing one step.
Description
From the ruby docs:
rewind → e
Rewinds the enumeration sequence by one step.
In practice, however, it fully rewinds (either change documentation or have it do what it says. Going back one step is nice though):
irb(main):001:0> a = [1,2,3,4]
=> [1, 2, 3, 4]
irb(main):002:0> b = a.to_enum
=> #<Enumerator: [1, 2, 3, 4]:each>
irb(main):007:0> b.next
=> 1
irb(main):008:0> b.next
=> 2
irb(main):009:0> b.next
=> 3
irb(main):010:0> b.rewind
=> #<Enumerator: [1, 2, 3, 4]:each>
irb(main):011:0> b.next
=> 1
Updated by matz (Yukihiro Matsumoto) over 12 years ago
It is a bug in documentation. #rewind method rewinds the sequence to the beginning.
Updated by matz (Yukihiro Matsumoto) over 12 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r34712.
Chris, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
- enumerator.c (enumerator_rewind): update the documentation.
fixed: #6053