Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs out of date? Undefined method Array#binary_search #4

Open
gkop opened this issue Jan 21, 2013 · 3 comments
Open

Docs out of date? Undefined method Array#binary_search #4

gkop opened this issue Jan 21, 2013 · 3 comments

Comments

@gkop
Copy link

gkop commented Jan 21, 2013

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>'
@Nerian
Copy link
Contributor

Nerian commented Jan 27, 2013

Same problem here. Using Mac OS.

@skandragon
Copy link

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

@mjc-gh
Copy link

mjc-gh commented Aug 11, 2015

It seems the native version does not define this method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants