You are browsing as a guest. Sign up (or log in) to start making projects!

1h 12m 30s logged

Pattern matching for sealed enums

Previously if you wanted to check sealed enums types and use them, you had to do very ugly syntax for actually getting the variant instance:

auto out = tryGet();
when(out) {
    Result.Success -> {
        auto suc = out as Result.Success;
        looks::say("Success! ${suc.out.x}");

Now you don’t have to do all of this:

when(tryGet()) {
    Result.Success suc -> {
        looks::say("Success! ${suc.out.x}");

This is just syntax improvement, doesn’t change the generated code or anything, just helps the developer

0
32

Comments 0

No comments yet. Be the first!