When the switch is the last statement in the function, each branch gets an implicit return. If you use ; to suppress the return, there is no break to replace it, so the branch falls through:
->
switch foo
when 0
// implicit `break`
else
console.log 'Not zero'
switch bar
when 0
/* implicit `return` */ 0
when 1
; // no `break` or `return` -- falls through!
else
throw new RangeError 'bar must be 0 or 1'
When the
switch
is the last statement in the function, each branch gets an implicitreturn
. If you use;
to suppress thereturn
, there is nobreak
to replace it, so the branch falls through: