Issue #7493 has been updated by knu (Akinori MUSHA).


?????¨ã??next?????²ã??è¾¼ã??ä½?ç½®ã??1.8???1.9以é????§ã?¯é????£ã?¦ã????¾ã?????
??´å???????ªã?¡ã?½ã????????ä¾???«å???????¨å???????????????????§ã????????

a=[1,2,3]
e=a.map!
p e.next #=> 1
p e.next #=> 2
p a #=> [nil, nil, 3] (1.8) [nil, 2, 3] (1.9+)

??¨ã??1.8??§ã??next??§å?¤ã??è¿???£ã?¦ã??????®ã??yield??«ã??????????­ã????¯å?¼å?ºã??çµ?äº???????å¾?ï¼???¨ã????????次ã?®ã????­ã????¯å?¼å?ºã???????£ã?????ï¼???§ã????????
1.9以é????§ã?¯å????®ã?¡ã?½ã????????yield????????´å????®ã?¿ã?¤ã????³ã?°ã?§å?¤ã??è¿???£ã?¦æ?¥ã??次ã??next??§å????®ã?¡ã?½ã???????«å?¶å¾¡?????»ã??????????«ã?ªã?£ã?¦ã????¾ã?????
ï¼?1.9以é????®æ?????????????¾ã???????¨æ???????¾ã??ï¼?
----------------------------------------
Bug #7493: ?????­ã????¯ã??渡ã??????????´å???????????1è¦?ç´???®ã?¿ã??è¿????Enumerator??«å¯¾??????next?????????ç¶?????????¨ã??2度ç?®ã??StopIterationä¾?å¤??????ºç????????
https://bugs.ruby-lang.org/issues/7493#change-34317

Author: kachick (Kenichi Kamiya)
Status: Closed
Priority: Normal
Assignee: 
Category: 
Target version: Ruby 1.8.7
ruby -v: ruby 1.8.7 (2012-10-12 patchlevel 371) [x86_64-linux]


????????­ã????¯ä???????§å?????????????´å?????????????«è????¤ã????£ã??1è¦?ç´???®ã?¿ã??è¿??????¡ã?½ã??????????????Enumerator???ä½??????¨ã??
2度ç?®ã??next???StopIterationä¾?å¤????è¿????????????§ã?????
????????³ã?£ã??????????§ç¢ºèª?????????¡ã?½ã???????¯ã??以ä????®ç?©ã?§ã?????

* Array#index
* Array#find_index
* Array#rindex
* Enumerable#detect
* Enumerable#find

????????¯ã??1.8.7???1.9?????®ä??æ§???«æ?¼ã?????å·®ç?°ã?¨è??????????¹ã????¯ã????®ã?§ã???????????ï¼?
???????????????Enumerator??«å¯¾??????to_a???????????¨å?¨è??ç´??????«ã??Array???è¿????äº??????????
1.8.7??«æ?¼ã????¦ã????¨è??ç´?èµ°æ?»å?ºæ?¥ã????¹ã????ªç?¶ã?§ã?¯ç?¡ã???????¨æ???????¾ã????????

# to_a??¨ã?®å·®??°ã?¯ã??dbussink??®æ???????§æ????¥ã??????¨ã????ºæ?¥ã?¾ã????????
# https://github.com/rubinius/rubinius/pull/2063#issuecomment-10881875

  array = [:a, :b, :c]
  index_enum = array.index
  index_enum.to_a #=> [:a, :b, :c]
  index_enum.next #=> :a
  index_enum.next #=> StopIteration: iteration reached at end


-- 
http://bugs.ruby-lang.org/