Closed ghost closed 6 months ago
Right now only fixed-number of type parameters are allowed, so a single Tuple
type would not be possible without adding the ability to handle variadic type parameters.
However something as simple as this could do the job in the meantime:
record <$A, $B> Tuple2 (a $A, b $B)
record <$A, $B, $C> Tuple3 (a $A, b $B, c $C)
record <$A, $B, $C, $D> Tuple4 (a $A, b $B, c $C, d $D)
record <$A, $B, $C, $D, $E> Tuple5 (a $A, b $B, c $C, d $D, e $E)
record <$A, $B, $C, $D, $E, $F> Tuple6 (a $A, b $B, c $C, d $D, e $E, f $F)
or whatever your preference for naming is, and then you can use them like this:
import basics
func main {
values <int, int, String> Tuple3 = Tuple3(10, 11, "Hello")
printf("a=%d b=%d c=%S\n", values.a, values.b, values.c)
}
.NET's
System.Tuple
.