empty_collection_literal - ApplebaumIan/BitbucketAPI GitHub Wiki
Empty Collection Literal
Prefer checking isEmpty over comparing collection to an empty array or dictionary literal.
- Identifier: empty_collection_literal
- Enabled by default: Disabled
- Supports autocorrection: No
- Kind: performance
- Analyzer rule: No
- Minimum Swift compiler version: 3.0.0
- Default configuration: warning
Non Triggering Examples
myArray = []
myArray.isEmpty
!myArray.isEmpty
myDict = [:]
Triggering Examples
myArray↓ == []
myArray↓ != []
myArray↓ == [ ]
myDict↓ == [:]
myDict↓ != [:]
myDict↓ == [: ]
myDict↓ == [ :]
myDict↓ == [ : ]