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:
Key Value severity warning ignore_swiftui_view_bodies false
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()
//
// ignore_swiftui_view_bodies: true
//
var body: some View {
let _ = foo()
return Text("Hello, World!")
}
Triggering Examples
↓let _ = foo()
if _ = foo() { ↓let _ = bar() }
var body: some View {
↓let _ = foo()
Text("Hello, World!")
}