Chapter 8 closures


While trying to get familiar with closures, I 'm facing other mismatches. No problems with closures functionality. Wonder why playground doesn’t let me run this code:

In the playground snapshot, you are missing an “=” sign in line 7. It should be

  let incrementCounter: () -> Int = {

Hi everyone, I also have a question about this subject, I take advantage that the code is already written.
I have a hard time to understand why the full function is not read every time by the program
So if we do
let counter1 = countingclosure()
If you do counter1 multiple times the value of counter evolves and don’t restart at 0
I don’t understand exactly why.

This topic was automatically closed after 166 days. New replies are no longer allowed.