Stream: beginners

Topic: can i check the length of tuple


view this post on Zulip Jonas (Dec 06 2024 at 15:06):

can i check the length of tuple or Pattern match on Tupel with Different Size

view this post on Zulip Anton (Dec 06 2024 at 15:18):

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

view this post on Zulip Richard Feldman (Dec 06 2024 at 15:25):

I think this is the first time anyone has asked about this, so I'm really curious what the use case is! :smiley:

view this post on Zulip Jonas (Dec 06 2024 at 15:26):

i thougth to have base case for some thing were i just have to elements in the tupel

view this post on Zulip Jonas (Dec 06 2024 at 15:26):

the third one is for an option

view this post on Zulip Jonas (Dec 06 2024 at 15:41):

i wanting to make range method were u give a Tupel instead of an struct as paramater

view this post on Zulip jan kili (Dec 07 2024 at 03:36):

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.

view this post on Zulip Luke Boswell (Dec 07 2024 at 03:38):

They are fixed at compile time, not something that can change size at runtime

view this post on Zulip jan kili (Dec 07 2024 at 03:38):

You could combine them with a tag union like TwoOrThreeStrings : [TwoStrings (Str, Str), ThreeStrings (Str, Str, Str)]

view this post on Zulip Anthony Bullard (Dec 07 2024 at 13:58):

Yeah and usually those different cases have a different semantic meaning in your program, so you can make the Tags much more meaningful

view this post on Zulip jan kili (Dec 07 2024 at 15:47):

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