Convert a Scala list to a tuple?

You can’t do this in a typesafe way. Why? Because in general we can’t know the length of a list until runtime. But the “length” of a tuple must be encoded in its type, and hence known at compile time. For example, (1,'a',true) has the type (Int, Char, Boolean), which is sugar for Tuple3[Int, Char, Boolean]. The reason tuples have this restriction is that they need to be able to handle a non-homogeneous types.

Leave a Comment