brewersfan1976

swap_case.rb

Feb 25th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.31 KB | None | 0 0
  1. def swapCase(text)
  2.     x = 0
  3.     length = text.length
  4.    
  5.     while (x < length)
  6.         if text[x] >= 'a' and text[x] <= 'z' then
  7.             text[x] = text[x].upcase!
  8.         else
  9.             text[x] = text[x].downcase!
  10.         end
  11.            
  12.         x = x + 1
  13.      end
  14.        
  15.      return text
  16. end
Advertisement
Add Comment
Please, Sign In to add comment