Skip to content

Commit 6ea34d9

Browse files
author
lev epshtein
committed
commit 2
1 parent e0577d0 commit 6ea34d9

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

closures/closure.insted.class.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
def make_multiplier_of(n):
2+
def multiplier(x):
3+
return x * n
4+
return multiplier
5+
6+
7+
# Multiplier of 3
8+
times3 = make_multiplier_of(3)
9+
10+
# Multiplier of 5
11+
times5 = make_multiplier_of(5)
12+
13+
# Output: 27
14+
print(times3(9))
15+
16+
# Output: 15
17+
print(times5(3))
18+
19+
# Output: 30
20+
print(times5(times3(2)))

0 commit comments

Comments
 (0)