Skip to content

Latest commit

 

History

History
49 lines (28 loc) · 545 Bytes

implicit_return.md

File metadata and controls

49 lines (28 loc) · 545 Bytes

Pattern: Missing use of implicit return

Issue: -

Description

Prefer implicit returns in closures.

Examples of correct code:

foo.map { $0 + 1 }


foo.map({ $0 + 1 })


foo.map { value in value + 1 }


func foo() -> Int {
  return 0
}


if foo {
  return 0
}


var foo: Bool { return true }

Examples of incorrect code:

foo.map { value in
  return value + 1
}


foo.map {
  return $0 + 1
}

Further Reading