From: Yusuke ENDOH Date: 2011-07-18T14:55:25+09:00 Subject: [ruby-core:38156] Re: [Ruby 1.9 - Feature #4766] Range#bsearch Oops, 2011/7/18 Yusuke ENDOH : >> Or just the first element that matches? > > Good question :-) �Interestingly, break can be used. > > �ary = [0, 4, 7, 10, 12] > �p (0..4).bsearch {|i| break i if ary[i] >= 4 } > � �#=> 1, 2, 3 or 4 (probably 2, but I don't think it might be changed > � � � �in future extension) � �#=> 1, 2, 3 or 4 (probably 2, but I don't think it might be changed � � � �in future extension) -- Yusuke Endoh