I\'m really confused with the ways we create an array in Swift. Could you please tell me how many ways to create an empty array with some detail?
Swift 5
There are three (3) ways to create a empty array in Swift and shorthand syntax way is always preferred.
Method 1: Shorthand Syntax
var arr = [Int]()
Method 2: Array Initializer
var arr = Array()
Method 3: Array with an Array Literal
var arr:[Int] = []
Method 4: Credit goes to @BallpointBen
var arr:Array = []