title: Understanding Ruby Enumerable#map (with more complex blocks)
body: <p>Let's say I have a function</p>
  
  <pre><code>def odd_or_even n
    if n%2 == 0
      return :even
    else
      return :odd
    end
  end
  </code></pre>
  
  <p>And I had a simple enumerable array</p>
  
  <pre><code>simple = [1,2,3,4,5]
  </code></pre>
  
  <p>And I ran it through map, with my function, using a do-end block:</p>
  
  <pre><code>simple.map do
    |n| odd_or_even(n)
  end
  # =&gt; [:odd,:even,:odd,:even,:odd]
  </code></pre>
  
  <p>How could I do this without, say, defining the function in the first place?  For example,</p>
  
  <pre><code># does not work
  simple.map do |n|
    if n%2 == 0
      return :even
    else
      return :odd
    end
  end
  
  # Desired result:
  # =&gt; [:odd,:even,:odd,:even,:odd]
  </code></pre>
  
  <p>is not valid ruby, and the compiler gets mad at me for even thinking about it.  But how would I implement an equivalent sort of thing, that works?</p>
  
  <p><em>edit</em></p>
  
  <p>In reality, the solution to my problem matters to me a lot less than the motivation/reasoning behind it, to help me understand more how ruby blocks work :)</p>