Toggle Bool
Prefer someBool.toggle()
over someBool = !someBool
- Identifier:
toggle_bool
- Enabled by default: No
- Supports autocorrection: Yes
- Kind: idiomatic
- Analyzer rule: No
- Minimum Swift compiler version: 5.0.0
- Default configuration:
Key Value severity warning
Non Triggering Examples
isHidden.toggle()
view.clipsToBounds.toggle()
func foo() { abc.toggle() }
view.clipsToBounds = !clipsToBounds
disconnected = !connected
result = !result.toggle()
Triggering Examples
↓isHidden = !isHidden
↓view.clipsToBounds = !view.clipsToBounds
func foo() { ↓abc = !abc }