swift - What's the difference between [String] vs. [(String)]? -
what's difference between [string] , [(string)] in swift? them using let arr1 : [string] , let arr2 = [string]().
[string] array of strings, while [(string)] array of tuples contain 1 string.
let arr1 = [("test")] arr1[0].0 // contains "test" let arr2 = ["test"] arr2[0] // contains "test" a more useful array of tuples might like:
let arr1: [(id: int, name: string)] = [(12, "fred"), (43, "bob")] arr1[0].name // contains "fred"
Comments
Post a Comment