title: Alternating cases in Ruby
body: <p>Working on a very simple task to return an uncapped string as capitals and vice versa, so for example:</p>
  <pre><code>&quot;hello world&quot;.to_alternating_case() === &quot;HELLO WORLD&quot;
  &quot;HELLO WORLD&quot;.to_alternating_case() === &quot;hello world&quot;
  &quot;hello WORLD&quot;.to_alternating_case() === &quot;HELLO world&quot;
  &quot;HeLLo WoRLD&quot;.to_alternating_case() === &quot;hEllO wOrld&quot;
  &quot;12345&quot;.to_alternating_case() === &quot;12345&quot; // Non-alphabetical characters are unaffected
  &quot;1a2b3c4d5e&quot;.to_alternating_case() === &quot;1A2B3C4D5E&quot;
  &quot;String.prototype.toAlternatingCase&quot;.to_alternating_case() === &quot;sTRING.PROTOTYPE.TOaLTERNATINGcASE&quot;
  </code></pre>
  <p>My initial thought was to use the swapcase method, which should work. But there's something wrong with my code and I can't quite figure it out.</p>
  <pre><code>class String
    def to_alternating_case(word)
   
      word.swapcase
    end
  end
  
  word = String.new
  </code></pre>
  <p>The error message:</p>
  <pre><code>#&lt;ArgumentError: wrong number of arguments (given 0, expected 1)&gt;
  main.rb:4:in `to_alternating_case'
  </code></pre>
  <p>Here is a <a href="https://www.codewars.com/kata/56efc695740d30f963000557/train/ruby" rel="nofollow noreferrer">link</a> to the kata</p>