Project

General

Profile

Bug #7725

bsearch should return enumerator when called without a block

Added by Marc-Andre Lafortune over 3 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Normal
[ruby-core:51564]

Description

bsearch should return enumerator when called without a block

This would allow, for example

values.bsearch.with_index{|val, index| val >= some_array[index]} # => a value

Otherwise, one must use zip/each_with_index and will get an array returned, not just the value seeked:

r = values.zip(some_array).bsearch{|val, other_val| val >= other_val}
a_value = r.first

Associated revisions

Revision 38984
Added by Marc-Andre Lafortune about 3 years ago

  • array.c (rb_ary_bsearch): Return enumerator if no block [#7725]

  • range.c (range_bsearch): ditto

  • test/ruby/test_array.rb: Test for above

  • test/ruby/test_range.rb: ditto

Revision 38984
Added by Marc-Andre Lafortune about 3 years ago

  • array.c (rb_ary_bsearch): Return enumerator if no block [#7725]

  • range.c (range_bsearch): ditto

  • test/ruby/test_array.rb: Test for above

  • test/ruby/test_range.rb: ditto

Revision 38984
Added by Marc-Andre Lafortune about 3 years ago

  • array.c (rb_ary_bsearch): Return enumerator if no block [#7725]

  • range.c (range_bsearch): ditto

  • test/ruby/test_array.rb: Test for above

  • test/ruby/test_range.rb: ditto

History

#1 [ruby-core:51752] Updated by Marc-Andre Lafortune about 3 years ago

  • Status changed from Open to Closed
  • Assignee set to Marc-Andre Lafortune

Fixed with r38984.

Also available in: Atom PDF