I need to test some complicated conditions to calculate a Return value. But MMa doesn't let you Return[] from anywhere the way C++ does. The structure of my Module is similar to this:
foo[x_] := Module[{},
Do[
If[x == (n^2), Return[0]];
If[x == (n^4), Return[1]],
{n, 1, 5}];
Return[2]];
If Return[] actually Return'd, foo[4] would return 0, but instead it returns 2.
Is there a way to do a return from an arbitrary place in the code?
I know that effete programmers will dislike my program structure, but I'm asking how to force the Return[], not how to restructure the program.