Hacker News new | ask | show | jobs
by andyjohnson0 4153 days ago
What are the advantages that language-level tuples would have over the existing System.Tuple class?
2 comments

Without deconstruction and pattern matching, language level tuples would be only sugar: "var x = (1, 2)" versus "var x = Tuple.Create(1,2)"

The real power of Tuples only comes with deconstruction and matching, such as "var (a,b) = GetSomething()" and "case (_, y)".

So these features would go hand in hand. Deconstruction and matching requires lang level tuples, and lang level tuples are pretty lame without deconstruction and pattern matching.

The ability to write (2, "hello") instead of Tuple.Create(2, "Hello"). But more importantly, syntax for deconstructing tuples will make tuples convenient for returning multiple values from a method. Eg.: (var x, var y) = getPoint(); as shown in the aticle.
Also, the type is simpler to represent. Instead of Tuple<int, string> you just have something like (Int, String).