title: Split and reverse in Ruby 2.1.1
body: <p>I'm working on a challenge at codeeval.com to practice Ruby (v. 2.1.1). The goal is to write a function that takes a string of words and then prints it out in reverse. Here's my function:</p>
  
  <pre><code>def rev(words)
    words.split(' ')
    words.reverse!.each{|word| print words}
    print '\n'
  end
  </code></pre>
  
  <p>What I'm expecting is along the lines of</p>
  
  <pre><code>#words = ["apple bat cat"]
  words.split(' ') #=&gt; words = ["apple", "bat", "cat"]
  words.reverse!.each{|word| print words} #=&gt; words = {"cat", "bat", "apple"}
  </code></pre>
  
  <p>which should print</p>
  
  <pre><code>$ cat bat apple
  </code></pre>
  
  <p>Instead, I'm getting the following error:</p>
  
  <pre><code>word_reverse.rb:5:in `rev': undefined method `each' for "\ndlrow olleh":String (NoMethodError)
      from word_reverse.rb:12:in `block in &lt;main&gt;'
      from word_reverse.rb:12:in `each'
      from word_reverse.rb:12:in `&lt;main&gt;'
  </code></pre>
  
  <p>I can't figure out why it's not working. Thoughts?</p>