Created
July 31, 2013 06:32
-
-
Save chiragmongia/6119810 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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