Comment

Comment by johnlcox

I haven't tried it with enums, but it should still be possible with Motif. I'll have to add some tests.

  match(enumValOpt)
      .when(some(eq(MyEnum.VALUEX))).then(() -> someFn(p1, p2))
      .when(some(eq(MyEnum.VALUEY))).then(() -> otherFn(p1, p2))
      .orElse(defaultValue)
      .doMatch();
It's a little longer than your example since there is support for more than just Optional, but it's pretty similar.
parent johnlcox 11 years ago

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton