title: Ruby Error with .length method
body: <p>I am running into an error with my code and I am not sure why. I am trying to create a function that returns the longest word in a string. The only built-in Ruby method I can use is .split. My code is below and the error I receive is below that. Any help with figuring this out would be appreciated. </p>
  
  <p>Thanks in advance.</p>
  
  <pre><code>def longest_word(sentence)
      sentence1 = sentence.split
      longest_word = ""
  
  for i in 0...sentence1.length
      if i.length &gt; longest_word.length 
          longest_word = i 
      end 
  end 
  return longest_word
  end
  
  longest_word("one three")
  </code></pre>
  
  <p>Error below:</p>
  
  <pre><code>undefined method `length' for 0:Fixnum
  (repl):15:in `block in longest_word'
  (repl):14:in `times'
  (repl):14:in `longest_word'
  (repl):29:in `&lt;main&gt;'
  </code></pre>