Skip to content

Latest commit

 

History

History
38 lines (19 loc) · 644 Bytes

unneeded_parentheses_in_closure_argument.md

File metadata and controls

38 lines (19 loc) · 644 Bytes

Pattern: Unneeded parentheses in closure argument

Issue: -

Description

Parentheses are not needed when declaring closure arguments.

Examples of correct code:

let foo = { (bar: Int) in }


let foo = { bar in }


let foo = { bar -> Bool in return true }

Examples of incorrect code:

call(arg: { (bar) in })


let foo = { (bar) -> Bool in return true }


foo.map { ($0, $0) }.forEach { (x, y) in }


foo.bar { [weak self](x, y) in }

Further Reading