Created
September 19, 2016 16:22
-
-
Save mrcampbell/73110a78328a97a4f6671372af060c1f to your computer and use it in GitHub Desktop.
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 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