Let’s start with just a pair — as you may know it takes generic types T1
, T2
, and T3
. Wait, a pair with three types? Oh yes, such simple type as tuple has many places where it can be improved. Adding extra type is one of such areas.
This additional type is not completely arbitrary as the rest of the type parameters — it is lowest common ancestor of them. Why do we need common type? For making a tuple a true member of collection family:
let pair Tuple<Int,Int,_> = ( 2, 3 ); let triple = ( 3, 7, 8 ); // reading elements via indexer let first = triple[0]; // iterating over tuple for elem in triple •••