SwiftLint
SwiftLint copied to clipboard
Empty Array Initialize
New rule request
array initialize using [] instead ()
Bad
var emptyArray = [Int]()
Good
var emptyArray: [Int] = []
- using [] is more common and preferred due to its readability and simplicity. It is a more straightforward way to indicate that you are initializing an empty array of a specific type.
- using () to initialize an empty array might lead to confusion, as it resembles tuple syntax, which may suggest that you are creating a tuple.