Ruby数组索引-每隔一个单词大写


wordSort.sort!
=begin
Conditional is performed on the array: if array index is equal to zero or has 
a remainder of zero after being divided by 2 then call upcase method on element.
Else call lowercase method on that index number.
=end
puts ""
puts "Here are the words you entered:"
puts wordSort
enum = [:upcase, :downcase].cycle
  #=> #<Enumerator: [:upcase, :downcase]:cycle> 
"Here are the words you entered:".gsub(/w+/) { |x| x.send enum.next }
  #=> "HERE are THE words YOU entered:"