Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between [String] vs. [(String)]?

Tags:

swift

What's the difference between [String] and [(String)] in Swift? I get them using let arr1 : [String] and let arr2 = [String]().

like image 986
Andrej Avatar asked Dec 03 '22 16:12

Andrej


1 Answers

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.

like image 112
Airspeed Velocity Avatar answered Jan 04 '23 01:01

Airspeed Velocity