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
答案 0 :(得分:1)
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:"