How to make a string 1st letter caps, 2nd letter noncaps, 3rd letter caps, 4th letter noncaps...?
<p>I want to change:</p>

<pre><code>word = "Stackoverflow is awesome!"
</code></pre>

<p>into:</p>

<pre><code>"StAcKoVeRfLoW Is aWeSoMe!"
</code></pre>

<p>I did:</p>

<pre><code>result = ""
a = word.length
odd = (1..a).select(&amp;:odd?)
even = (1..a).select(&amp;:even?)
odd.each {|i| even.each {|b| result += word[b].to_s}}
result # =&gt; "akvrlwi wsm!akvrlwi wsm!akvrlwi wsm!akvrlwi wsm!akvrlwi wsm!akvrlwi wsm!akvrlwi wsm!akvrlwi wsm!akvrlwi wsm!akvrlwi wsm!akvrlwi wsm!akvrlwi wsm!akvrlwi wsm!"
</code></pre>