Bug #7726

bsearch should handle block result in a consistent way

Added by Marc-Andre Lafortune about 1 year ago. Updated about 1 year ago.

[ruby-core:51565]
Status:Closed
Priority:Normal
Assignee:Marc-Andre Lafortune
Category:core
Target version:2.0.0
ruby -v:r38825 Backport:

Description

The documentation states that the block of bsearch must
return either true/false or a number.

If the block returns another object (other than nil), I feel that either
1) It should be considered as 'truthy'
2) It should raise a TypeError

Currently it does not raise an error and returns a result different than if true was passed:

(1..3).bsearch{ 'x' } == (1..3).bsearch{ true } # => false

Associated revisions

Revision 38988
Added by Marc-Andre Lafortune about 1 year ago

  • array.c (rbarybsearch): Fix r38986 (typo) [Bug #7726]

  • range.c (range_bsearch): ditto

History

#1 Updated by Marc-Andre Lafortune about 1 year ago

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

Fixed with r38986.

Also available in: Atom PDF