I was working with swift and got a question from somewhere but didn't understand what output will I get while running the function.
import UIKit
var i = 0
var closureArray : [() -> ()] = []
for _ in 1...5{
closureArray.append {
print(i)
}
i += 1
}
what will I get when I will type:-
closureArray[0]()
I know the answer but i want to know the explanation behind it.