Home > Articles > Data > SQL Server

  • Print
  • + Share This
Like this article? We recommend

Tuple Types

Whether or not a tuple uses labels affects the tuple's type. An unlabeled tuple is simply an ordered list of types, whereas a tuple with field names uses those labels as part of its type:

// Type (Int, String, Double)
let unlabeledTuple = (1, "Hello", 2.2)
// Type (a: Int, b: String, c: Double)
let labeledTuple = (a:1, b:"Hello", c:2.2)

With this label rule, the following type alias:

typealias LabeledTupleType = (a:Int, b:String, c:Double)

is not equivalent to this type alias:

typealias UnlabeledTupleType = (Int, String, Double)

because the latter doesn't include labels. This difference is most important when you use tuples as argument lists for closures, functions, and methods.

  • + Share This
  • 🔖 Save To Your Account