SwiftLint icon indicating copy to clipboard operation
SwiftLint copied to clipboard

Empty Array Initialize

Open inotetw opened this issue 1 year ago • 2 comments

New rule request

array initialize using [] instead ()

Bad

var emptyArray = [Int]()

Good

var emptyArray: [Int] = []
  1. 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.
  2. using () to initialize an empty array might lead to confusion, as it resembles tuple syntax, which may suggest that you are creating a tuple.

inotetw avatar Aug 04 '23 07:08 inotetw