Stream: beginners

Topic: matching on variable


view this post on Zulip Nick Hallstrom (Mar 14 2023 at 19:28):

Is there a way to match where the left hand side of the arrow is a variable? For example

a = 10

when foo is
    ^a -> "Only matches when foo is 10"
    _  -> ""

view this post on Zulip Brendan Hansknecht (Mar 14 2023 at 19:41):

I think we added guard clauses:
x if x == a -> ...

view this post on Zulip Nick Hallstrom (Mar 14 2023 at 19:54):

Oh ya, duh :man_facepalming: I think that should totally work, thanks!


Last updated: Jul 06 2025 at 12:14 UTC