title: Declaring an integer Range with step != 1 in Ruby
body: <p><strong>UPDATE 2</strong>: For posterity, this is how I've settled on doing it (thanks to Jorg's input):</p>
  
  <pre><code>100.step(2, -2) do |x|
      # my code
  end
  </code></pre>
  
  <p>(Obviously there are plenty of ways to do this; but it sounds like this is the most "Ruby" way to do it; and that's exactly what I was after.)</p>
  
  <hr>
  
  <p><strong>UPDATE</strong>: OK, so what I was looking for was <code>step</code>:</p>
  
  <pre><code>(2..100).step(2) do |x|
      # my code
  end
  </code></pre>
  
  <p>But it turns out that I wasn't 100% forthcoming in my original question. I actually want to iterate over this range backwards. To my surprise, a negative step isn't legal.</p>
  
  <pre><code>(100..2).step(-2) do |x|
      # ArgumentError: step can't be negative
  end
  </code></pre>
  
  <p>So: <strong>how do I do this backwards?</strong></p>
  
  <hr>
  
  <p>I am <strong>completely new</strong> to Ruby, so be gentle.</p>
  
  <p>Say I want to iterate over the range of even numbers from 2 to 100; how would I do that?</p>
  
  <p>Obviously I <em>could</em> do:</p>
  
  <pre><code>(2..100).each do |x|
      if x % 2 == 0
          # my code
      end
  end
  </code></pre>
  
  <p>But, <em>obviously</em> (again), that would be pretty stupid.</p>
  
  <p>I know I could do something like:</p>
  
  <pre><code>i = 2
  while i &lt;= 100
      # my code
      i += 2
  end
  </code></pre>
  
  <p>I believe I could also write my own custom class that provides its own <code>each</code> method (?). I am almost sure that would be overkill, though.</p>
  
  <p>I'm interested in two things:</p>
  
  <ol>
  <li>Is it <strong>possible</strong> to do this with some variation of the standard Range syntax (i.e., <code>(x..y).each</code>)?</li>
  <li>Either way, what would be the most idiomatic "Ruby way" of accomplishing this (using a Range or otherwise)? Like I said, I'm new to the language; so any guidance you can offer on how to do things in a more typical Ruby style would be much appreciated.</li>
  </ol>