Why does this:
def make_fib():
cur, next = 0, 1
def fib():
nonlocal cur, next
result = cur
cur, next = next, cur + next
return result
return fib
Work differently than:
def make_fib():
cur, next = 0, 1
def fib():
nonlocal cur, next
result = cur
cur = next
next = cur + next
return result
return fib
I see how the second one messes up because at cur = next and next = cur + next because essentially it will become next = next + next but why does the first one run differently?
next = result + next