From: "David A. Black" Date: 2004-09-20T01:01:18+09:00 Subject: Re: Array#index block and rdetect Hi -- On Sun, 19 Sep 2004, trans. (T. Onoma) wrote: > Tiny RCR suggestion: > > Array#index optionally take a block like Enumerable#detect does. > > ['a','b','c'].index{|e| e == 'b'} # => 1 > ['a','b','c'].index{|e| e == 'c'} # => 2 > ['a','a','a'].index{|e| e == 'a'} # => 0 > ['a','a','a'].index{|e| e == 'b'} # => nil See the thread at http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/105314 for a recent discussion of this. I basically like the idea, with a couple of caveats which are discussed in that thread. David -- David A. Black dblack@wobblini.net