Created
September 27, 2013 06:05
-
-
Save pjc0247/6724697 to your computer and use it in GitHub Desktop.
Ruby String Extension
This file contains 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
class String | |
def left(n) | |
return self if n > self.length | |
self.slice(0, n) | |
end | |
def right(n) | |
return self if n > self.length | |
self.slice(self.length-n, n) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment