# enum\_for(:each\_with\_index)$B$NAj0c(B

**URL:** <https://www.ruby-forum.com/t/enum-for-each-with-index-b-naj0c-b/137298>\
**Category:** Development\
**Created:** [May 11, 2008, 5:53pm UTC](https://www.ruby-forum.com/t/enum-for-each-with-index-b-naj0c-b/137298 "2008-05-11T17:53:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [May 11, 2008, 5:53pm UTC](https://www.ruby-forum.com/t/enum-for-each-with-index-b-naj0c-b/137298/1 "2008-05-11T17:53:43Z")

</div>

e$B$k$S$-$A$G$9!#e(B

Ruby 1.8.7e$B$He(BRuby 1.9e$B$Ne(B each\_with\_index  
e$B$Ne(BEnumeratore$B$N5sF0$,0[$J$j$^$9!#e(B

require ‘enumerator’  
RUBY\_VERSION # =\> “1.8.6”  
%w[foo bar].enum\_for(:each\_with\_index).select {|x,i| i\>=1 } # =\>  
[[“bar”, 1]]

require ‘enumerator’  
RUBY\_VERSION # =\> “1.8.7”  
%w[foo bar].enum\_for(:each\_with\_index).select {|x,i| i\>=1 } # =\>  
[[“bar”, 1]]

require ‘enumerator’  
RUBY\_VERSION # =\> “1.9.0”  
%w[foo bar].enum\_for(:each\_with\_index).select {|x,i| i\>=1 } # =\> [“bar”]

RUBY\_VERSION # =\> “1.8.7”  
%w[foo bar].each\_with\_index.select {|x,i| i\>=1 } # =\> [[“bar”, 1]]

RUBY\_VERSION # =\> “1.9.0”  
%w[foo bar].each\_with\_index.select {|x,i| i\>=1 } # =\> [“bar”]

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [May 12, 2008, 1:26pm UTC](https://www.ruby-forum.com/t/enum-for-each-with-index-b-naj0c-b/137298/2 "2008-05-12T13:26:29Z")

</div>

At Mon, 12 May 2008 00:52:52 +0900,  
removed\_email\_address@domain.invalid wrote:

> Ruby 1.8.7ã¨Ruby 1.9ã® each\_with\_index ã®Enumeratorã®æŒ™å‹•ãŒç•°ãªã‚Šã¾ã™ã€‚  
> RUBY\_VERSION # =\> “1.8.7”  
> %w[foo bar].each\_with\_index.select {|x,i| i\>=1 } # =\> [[“bar”, 1]]
> 
> RUBY\_VERSION # =\> “1.9.0”  
> %w[foo bar].each\_with\_index.select {|x,i| i\>=1 } # =\> [“bar”]

ã€€[ruby-dev:32708]â†’[ruby-dev:32745]ã¨ã„ã†æµã‚ŒãŒã‚ã‚‹ã‚ˆã†ãªã®ã§  
1.9ã‚’ä¿®æ­£ã—ã¾ã—ãŸã€‚to\_aã‚’æŒŸã‚€ã¨æŒ™å‹•ãŒå¤‰ã‚ã‚‹ã¨ã„ã†ã®ã¯æ°—æŒã¡æ‚ªã„  
ã“ã¨ã‚‚ã‚ã‚Šã¾ã™ã—ã­ã€‚
