I find myself doing this pattern more often than not. Is there a better syntax/patten I could use for this?
On one hand I want to deconstruct the pattern so I can access properties of the payload (for instance, for Dir I use .children, but on the other hand, I still need the element with the constructor+payload (Dir or File).
I "wish" there was something like (pseudo-code)
when diskObject is
(Dir { children } as dirInner) as dirOuter -> ...
(File fileInner) as fileOuter -> ...
This is what I do at the moment, but feels clunky:
image.png
You can use diskObject again instead of the suggested as xOuter.
Let me try that, didn't occur to me
Yeah, it took me a while as well :)
It works! You're a boss @Anton :pray:
Fábio Beirão has marked this topic as resolved.
Extra note, i think the as syntax your wrote above should work in pattern matching. I just don't think it does currently.
Last updated: Nov 09 2025 at 12:14 UTC