Created
January 20, 2015 17:11
-
-
Save kumagi/b9af519cda3d8ec71e79 to your computer and use it in GitHub Desktop.
pythonのクロージャ…
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
def hoge(): | |
x = [] | |
def append(v): | |
x.append(v) | |
def printOut(): | |
print(x) | |
return (append, printOut) | |
appender, printer = hoge() | |
appender(1) | |
appender(2) | |
appender(3) | |
printer() | |
a, b = hoge() | |
a(4) | |
a(5) | |
a(6) | |
b() | |
printer() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment