title: Problem with binary search algorithm in ruby
body: <pre><code>def binarysearch(a, b,  tofind, stringarray)
    k=(a+b)/2
    if a==b
      return nil
    end
    if (stringarray[k]).include? tofind
      return stringarray[k]
    end
    if (stringarray[k]&lt;=&gt;tofind)==1
      binarysearch(a,k,tofind,stringarray)
    end
    if (stringarray[k]&lt;=&gt;tofind)==-1
      binarysearch(k,b,tofind,stringarray)
    end
    if (stringarray[k]&lt;=&gt;tofind)==0
      return stringarray[k]
    end
  end
  </code></pre>
  
  <p>This is a binary search algorithm. The a and b are the array indices that it is working on, tofind is a string that it is searching for, and stringarray is an array of strings. Unfortunately, every time that I try to run this function I get the following syntax error:</p>
  
  <pre><code>undefined method `include?' for 1:Fixnum (NoMethodError)`
  </code></pre>
  
  <p>But this is not a fixnum. I am pretty new to Ruby, so I could easily be missing something obvious. Any advice? </p>
  
  <p>This is where I declare stringarray: (Netbeans says that it is an array)</p>
  
  <pre><code>  strings=Array.new
    newstring=""
    until newstring=="no" do
      newstring=gets.chomp
      strings[strings.size]=newstring
    end
  </code></pre>