Skip to content

Instantly share code, notes, and snippets.

@mrcampbell
Created September 19, 2016 16:22
Show Gist options
  • Save mrcampbell/73110a78328a97a4f6671372af060c1f to your computer and use it in GitHub Desktop.
Save mrcampbell/73110a78328a97a4f6671372af060c1f to your computer and use it in GitHub Desktop.
class Chain():
def __init__(self):
self.exampleString = ''
def prepend(self, str):
self.exampleString = str + self.exampleString;
return self
def append(self, str):
self.exampleString = self.exampleString + str
return self
def print(self):
print(self.exampleString)
foo = Chain()
foo.append(' works').prepend(' this').prepend('Hey,').append('!').print()
# prints "Hey, this works!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment