Skip to content
New issue

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? Sign in to your account

Example in the chapter about returning closures works but with warnings #251

Open
fmad opened this issue Jan 7, 2024 · 0 comments
Open

Comments

@fmad
Copy link

fmad commented Jan 7, 2024

In the chapter about returning closures from functions, the 2nd example of a "shorthand" way to invoke a closure that is returned from a function reads:

let result2 = travel()("London")

Even though this does work, it not only looks strange but can be misleading, plus, throws a warning in the Playground, and rightfully so, as in this example we're trying to assign the non-existing return value to a constant.

Steps to reproduce

Copy/paste the code into a Playground and see.

Expected behavior

Either use a closure that returns something or don't try to capture the result, like this:

travel()("London")

Actual behavior

image

Environment

  • iOS Version: 17.2.1
  • Unwrap App Version: Latest
  • Device: iPhone Pro 13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant