can i check the length of tuple or Pattern match on Tupel with Different Size
can i check the length of tuple
No sorry
Pattern match on Tupel with Different Size
That should work, it does have some limitations right now #5530 #6802
I think this is the first time anyone has asked about this, so I'm really curious what the use case is! :smiley:
i thougth to have base case for some thing were i just have to elements in the tupel
the third one is for an option
i wanting to make range method were u give a Tupel instead of an struct as paramater
I believe that doesn't make sense in Roc because (Str, Str)
is a completely distinct type from (Str, Str, Str)
, so you couldn't pass one instead of the other.
They are fixed at compile time, not something that can change size at runtime
You could combine them with a tag union like TwoOrThreeStrings : [TwoStrings (Str, Str), ThreeStrings (Str, Str, Str)]
Yeah and usually those different cases have a different semantic meaning in your program, so you can make the Tags much more meaningful
Absolutely - my example would be way better contextualized like SameAgeSiblings : [Twins (Str, Str), Triplets (Str, Str, Str)]
Last updated: Jul 06 2025 at 12:14 UTC