Tuple subtypes (by labels)

Continuing the discussion from Tuples conform to Equatable:

I know that functions that take an Optional parameter can use a non-optional instance as an argument. Do tuples have the same relationship? I mean that is a tuple with at least one label member a sub-type of a tuple with the same shape but (at least) some labeled members become unlabeled? [...]

Is there such a relationship between tuple types? If not, should we add it? I think so.

There is already such relationship, but it goes both ways, so we cannot say that labelled is a subtype of unlabelled, or vice versa

check out this code:

var labelled: (a: Int, b: Int) = (a: 1, b: 2)
var unlabelled: (Int, Int) = (3, 4)

labelled = unlabelled
unlabelled = labelled
// labelled = (c: 5, d: 6) doesn't compile

As I already replied in that thread, the relation between tuple types is as follows:

Terms of Service

Privacy Policy

Cookie Policy