这种类型的名称是什么?
What is the name of this type?
在我的应用中,我使用了一个非常复杂的数据结构:
[(category: String, items: [(String, String)])]
我知道:
[Int]
是 "an array of Int
"
(String, String)
是 "a tuple of String
and String
"
那么我应该怎么称呼上面的类型呢?
可能
An array of tuples of String
and an array of tuples of String
and String
?
但这听起来像三种类型:
[(String)] and [(String)] and String
这有点令人困惑。
这种类型应该怎么称呼?
不要过度使用元组。为外部元组创建类型:
struct MyStruct {
var category : String
var items : [(String, String)]
}
现在说这是什么就容易多了:它是一个 MyStruct 数组。
在我的应用中,我使用了一个非常复杂的数据结构:
[(category: String, items: [(String, String)])]
我知道:
[Int]
是 "an array ofInt
"(String, String)
是 "a tuple ofString
andString
"
那么我应该怎么称呼上面的类型呢?
可能
An array of tuples of
String
and an array of tuples ofString
andString
?
但这听起来像三种类型:
[(String)] and [(String)] and String
这有点令人困惑。
这种类型应该怎么称呼?
不要过度使用元组。为外部元组创建类型:
struct MyStruct {
var category : String
var items : [(String, String)]
}
现在说这是什么就容易多了:它是一个 MyStruct 数组。