title: Comparison of Fixnum with nil failed - palindrome program Ruby
body: <p>I was working on a program for question 4 in Project Euler - find the largest palindrome among multiples of 3-digit numbers.  This is what I wrote:</p>
  
  <pre><code>def palintest(number)
      num = number.to_s
      len = num.length
  
      if len  % 2 != 0
          num[(len/2).floor] = ''
      end
  
      if num[0.. (len/2)-1] == num [len/2..len].reverse!
          return number
      end
  end
  
  palindromes = []
  
  for i in 100..999
      for j in 100..999
          palindromes &lt;&lt; palintest(i*j)
      end
  end
  
  puts palindromes.max
  </code></pre>
  
  <p>I got an error that says:</p>
  
  <pre><code>comparison of Fixnum with nil failed
  (repl):24:in `each'
  (repl):24:in `max'
  (repl):24:in `initialize'
  </code></pre>
  
  <p>I can't really figure out what's going on, I've tested each component of the program and it seems to be in working order.  Any help would be appreciated.</p>