What's the difference between [String] and [(String)] in Swift?
I get them using let arr1 : [String]
and let arr2 = [String]()
.
There should be no difference – this is a glitch somewhere in Xcode or Swift if you see [(String)]
. In theory, all variables are single element tuples – this is why every variable has a .0
property:
let s = "hello"
print(s.0)
but in practice this ought to get normalized out so that you never see (OneThing)
, only ever OneThing
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With