Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.
Already on GitHub?
to your account
One approach to using nested functions is grouping pieces of code, for instance, configuration of several views in a function called `configureViews`.
In such task, the natural way of looking at it would be to call the functions first, as they serve as a sort of summary, and then define the functions later.
Doing so will result in the following error being displayed:
`Use of local variable `[functionName]` before its declaration`
See attached Playground.
The text was updated successfully, but these errors were encountered:
Since nested functions can capture local variables, the place where they are declared is significant.
Sorry, something went wrong.
Comment by Mariano Abdala (JIRA)
Then I would understand that variables are defined before the functions are, and that variables are defined before the functions are invoked, but not that definition of functions need to precede its invocation. At least from a Swift `consumer` side.
That's not sufficient when a variable (as opposed to a constant) is captured by value (using a capture list). You have to know when the capture happens to know what the value is.
Cool, just trying to understand. Thanks.
No branches or pull requests