Penutupan di Python
def make_counter():
count = 0
def inner():
nonlocal count
count += 1
return count
return inner
King Generous
def make_counter():
count = 0
def inner():
nonlocal count
count += 1
return count
return inner
def make_summer():
data = []
def summer(val):
data.append(val)
_sum = sum(data)
return _sum
return summer