Redundant Discardable Let

Prefer _ = foo() over let _ = foo() when discarding a result from a function

  • Identifier: redundant_discardable_let
  • Enabled by default: Yes
  • Supports autocorrection: Yes
  • Kind: style
  • Analyzer rule: No
  • Minimum Swift compiler version: 5.0.0
  • Default configuration:
    KeyValue
    severity warning

Non Triggering Examples

_ = foo()
if let _ = foo() { }
guard let _ = foo() else { return }
let _: ExplicitType = foo()
while let _ = SplashStyle(rawValue: maxValue) { maxValue += 1 }
async let _ = await foo()

Triggering Examples

let _ = foo()
if _ = foo() { let _ = bar() }