Why is the compiler asking me for an `else` branch...
# getting-started
a
Why is the compiler asking me for an
else
branch when I have covered all of the possible subclasses of
Foo
(sealed class) ? Was it always like this? I remember not having to implement an
else
branch before.
r
No it wasn’t recently I faced the same with enums as well
a
k
Your code sample compiles and runs just fine.
a
You can see in my screenshot that it doesn’t.
k
What version of Kotlin are you using? The code works in both 1.5.31, 1.6.0 and 1.6.10. Also, you can see it working here: https://pl.kotl.in/ELzXUsA6I