Skip to content

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

@fmad

Description

@fmad

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions