Skip to content

Instantly share code, notes, and snippets.

@chiragmongia
Created July 31, 2013 06:32
Show Gist options
  • Select an option

  • Save chiragmongia/6119810 to your computer and use it in GitHub Desktop.

Select an option

Save chiragmongia/6119810 to your computer and use it in GitHub Desktop.
#Inverse Case
#Overwrite the default 'to_s' method such that it inverses the case of each letter.
#Eg: "hello WORLD".to_s -> "HELLO world"
class String
def to_s
self.swapcase
end
end
#Main
p "Enter the string"
line = gets.chomp
p "---Swapping the case of string---"
p line.to_s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment