在我的应用中,我使用了一个非常复杂的数据结构:
[(category: String, items: [(String, String)])]
我知道:
[Int]
是“Int
的数组”(String, String)
是“String
和String
的元组”
那么我应该怎么称呼上面的类型呢?
也许
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 数组。
关于swift - 这种类型的名称是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36806408/