def makeAdder(n):
def adder(m):
return m + n
return adder
plusThree = makeAdder(3)
self.say(plusThree) # plusThree is some kind of function...
self.say(plusThree(2)) # but this produces [object Object], not 5
self.say(plusThree(2).next().value) # oddly enough, this produces 5
I have no idea what's going on under the hood, but it looks like plusThree(2) returns some kind of iterator.
I have no idea what's going on under the hood, but it looks like
plusThree(2)
returns some kind of iterator.