Unwrap icon indicating copy to clipboard operation
Unwrap copied to clipboard

Example in the chapter about returning closures works but with warnings

Open fmad opened this issue 2 years ago • 0 comments

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

fmad avatar Jan 07 '24 16:01 fmad