binary_search icon indicating copy to clipboard operation
binary_search copied to clipboard

Docs out of date? Undefined method Array#binary_search

Open gkop opened this issue 12 years ago • 3 comments

Following the readme:

$ gem install binary_search
Fetching: binary_search-0.3.0.gem (100%)
Building native extensions.  This could take a while...
Successfully installed binary_search-0.3.0
1 gem installed
$ irb
1.9.3-p327 :001 >     require 'binary_search/native'
 => true 
1.9.3-p327 :002 > x = [5,1,6,7,2,6,4,2,6,1,6,1,1,8,3,5,2].sort
 => [1, 1, 1, 1, 2, 2, 2, 3, 4, 5, 5, 6, 6, 6, 6, 7, 8] 
1.9.3-p327 :004 > target = 4
 => 4 
1.9.3-p327 :005 > y = [[1,:a], [2,:b], [3,:c], [4,:d]]
 => [[1, :a], [2, :b], [3, :c], [4, :d]] 
1.9.3-p327 :006 >  puts x.binary_search { |v| target <=> v[0] }
NoMethodError: undefined method `binary_search' for [1, 1, 1, 1, 2, 2, 2, 3, 4, 5, 5, 6, 6, 6, 6, 7, 8]:Array
    from (irb):6
    from /home/gabe2/.rvm/rubies/ruby-1.9.3-p327/bin/irb:13:in `<main>'

gkop avatar Jan 21 '13 23:01 gkop

Same problem here. Using Mac OS.

Nerian avatar Jan 27 '13 16:01 Nerian

It works for me... Also using OS X.

skandragon avatar Dec 29 '13 00:12 skandragon

It seems the native version does not define this method.

mjc-gh avatar Aug 11 '15 23:08 mjc-gh