I am writing UnityScript code and at some point in my program I want to end a function from a block switch. This is my version of my code:
function Move(target: int) {
var targetTransform : Transform;
switch (target) {
case 0:
break;
case 1:
return;
default:
}
object.Move(targetTransform);
}
Now for some reason the compiler gives me
Assets/Scripts/GameMaster.js(490,9): BCW0015: WARNING: Unreachable code detected.
A line is a line containing switch.
From my previous research, I found many similar problems, but they all had actually unattainable code, for example, breakfor operators after returnor returnat the end, for example , although each case returned at some point. This is not the case here, I just want one of mine caseto return completely from the function, and the rest breakfrom switchand continue from there.
? , ?
, boolean switch... case .