Skip to content

Instantly share code, notes, and snippets.

@pjc0247
Created September 27, 2013 06:05
Show Gist options
  • Save pjc0247/6724697 to your computer and use it in GitHub Desktop.
Save pjc0247/6724697 to your computer and use it in GitHub Desktop.
Ruby String Extension
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