Incrementer using nested function swift

By | August 1, 2016

Incrementer using nested function swift

Swift provides nice feature of nested function. Here, in this example when we create a constant newIncrementer which refers to makeIncrement function that creates a copy of makeIncrement function.

Amount we pass in it, is stored within that copy. copy of the total variable increases every time that function is called.