`return` in Ruby Array#map : <p>I have a method where I would like to decide what to return within a map function. I am aware that this can be done with assigning a variable, but this is how I though I could do it;</p>

<pre><code>def some_method(array)
    array.map do |x|
      if x &gt; 10
         return x+1 #or whatever
      else
         return x-1
      end
    end
end
</code></pre>

<p>This does not work as I expect because the first time <code>return</code> is hit, it returns from the method, and not in the map function, similar to how the return is used in javascript's map function.</p>

<p>Is there a way to achieve my desired syntax? Or do I need to assign this to a variable, and leave it hanging at the end like this:</p>

<pre><code>def some_method(array)
    array.map do |x|
      returnme = x-1
      if x &gt; 10
         returnme = x+1 #or whatever
      end
      returnme
    end
end
</code></pre>
