What is the difference between below declaration of array syntax in swift?
var arr:[Int]
var arr=Array<Int>()
and which one is better? How and Why?
What is the difference between below declaration of array syntax in swift?
var arr:[Int]
var arr=Array<Int>()
and which one is better? How and Why?
var arr:[Int] This one simply declares an array of Integers named arr. It does not initialise the array and hence is not usable.
var arr=Array() This one declares as well as initialises the array. We can add whatever we want to this arr.
The second one is better since its initialised and usable.