Closed fgerschau closed 4 years ago
Such feature would be really helpful. As #781 shows, there is currently missing a straightforward way to ignore the last else block of a if/elseif/else. In my case, I usually list all possible states explicitly for readability, and use else block for invalid state. Even though in theory it's impossible to reach such block by code, it could reached be by a bug elsewhere in code.
// type is allowed to be X or Y only here
if (type instanceof X) {
// do something
} else if (type instanceof Y) {
// do something
} else {
throw new Error("Invalid state");
}
wrong repository (this one is not being maintained)
@fgerschau Could you please port the PR to the correct repository? Thanks a lot!
Closes #781
This is my first contribution here. I'm not sure using this.currentState for this is the best way to do it but I'm open to suggestions :)