Forum: Ruby-core [ruby-trunk - Bug #7726][Open] bsearch should handle block result in a consistent way

Posted by marcandre (Marc-Andre Lafortune) (Guest)
on 2013-01-22 10:52
(Received via mailing list)
Issue #7726 has been reported by marcandre (Marc-Andre Lafortune).

----------------------------------------
Bug #7726: bsearch should handle block result in a consistent way
https://bugs.ruby-lang.org/issues/7726

Author: marcandre (Marc-Andre Lafortune)
Status: Open
Priority: Normal
Assignee:
Category: core
Target version: 2.0.0
ruby -v: r38825


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
Posted by marcandre (Marc-Andre Lafortune) (Guest)
on 2013-01-30 07:02
(Received via mailing list)
Issue #7726 has been updated by marcandre (Marc-Andre Lafortune).

Status changed from Open to Closed
Assignee set to marcandre (Marc-Andre Lafortune)

Fixed with r38986.
----------------------------------------
Bug #7726: bsearch should handle block result in a consistent way
https://bugs.ruby-lang.org/issues/7726#change-35717

Author: marcandre (Marc-Andre Lafortune)
Status: Closed
Priority: Normal
Assignee: marcandre (Marc-Andre Lafortune)
Category: core
Target version: 2.0.0
ruby -v: r38825


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
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.