Closed alejandrobabio closed 3 years ago
irb(main):002:0> ary = [0, 4, 7, 10, 12]
=> [0, 4, 7, 10, 12]
irb(main):012:0> ary.bsearch {|e| 10 - e}
=> 10
irb(main):013:0> ary.find {|e| e == 10}
=> 10
After reading the Array#bsearch
docs I understood that it doesn't work with an equal condition, and the block could need to be rewritten to match the bsearch
requirements. So, I close this issue.
A simple example with a sorted array: