在 Swift 中,如果类型被括起来意味着什么,例如。 “(细绳)”

In Swift what does it mean if a type is bracketed, eg. "(String)"

简单的问题,很难Google并且不记得在文档中看到过这个问题。下面的代码将变量显示为“(String)”,而不仅仅是 "String" 这是什么意思?

var myDictionary = [String:Bool]()
// put whatever data you want in there, for example
myDictionary["cat"] = true
var firstKey = [String](myDictionary.keys)[0] //firstKey is type (String) as opposed to "String"
var myString = "this is my string" // has type String
var myOptionalString: String?  // has type String?
var myUninitializedString: String!  // has type String!

我想这可能与推断类型有关?

截图(来自代码完成window,一种快速检查类型的方法):

谢谢

这意味着它是一个单元素元组,其行为与同一类型的非元组完全相同。不用担心。