swift - 这种类型的名称是什么?

标签 swift types terminology

在我的应用中,我使用了一个非常复杂的数据结构:

[(category: String, items: [(String, String)])]

我知道:

  • [Int] 是“Int 的数组”
  • (String, String) 是“StringString 的元组”

那么我应该怎么称呼上面的类型呢?

也许

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 数组。

关于swift - 这种类型的名称是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36806408/

相关文章:

ios - 为什么 swift 在 ProductModule-Swift.h 中找不到我的 Objective-C 类

ios - 如果我的应用程序中的方向受限,如何手动确定设备方向?

ios - 调整文本的字体大小以适应 UIButton

c# 等价于 c++/cli long

go - 继承和接口(interface)

objective-c - 在 Swift 中为 NSOutputStream 设置 TCP_NODELAY

haskell - 具有私有(private)类型的类型签名

javascript - 如何从 unicode 字符中获取 charCode?

cuda - 高性能计算术语 : What's a GF/s?

c# - 什么是值类,什么是 C# 中的引用类?