Created
August 2, 2015 06:43
-
-
Save liuhuajin/7facd877ff3d23672795 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
def too_big(limit): | |
def compare(x): | |
return x > limit | |
return compare | |
f = too_big(100) | |
print f(100) | |
print f(101) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment