Skip to content

Instantly share code, notes, and snippets.

@dherman
Created October 13, 2012 02:14
Show Gist options
  • Save dherman/3882943 to your computer and use it in GitHub Desktop.
Save dherman/3882943 to your computer and use it in GitHub Desktop.
imperative control-flow and type-checking
public class DoFail {
public int f() {
do {
if (false) break;
return 0;
} while (true);
}
}
public class DoPass {
public int f() {
do {
return 0;
} while (true);
}
}
public class ForFail {
public int f() {
for (int x = 0; x < 10; x++) {
return x;
}
}
}
public class SwitchDefaultFail {
public int f(int x) {
switch (x) {
case 0:
if (false) break;
default:
return x;
}
}
}
public class SwitchDefaultPass {
public int f(int x) {
switch (x) {
case 0:
default:
return x;
}
}
}
public class SwitchNoDefaultFail {
public int f(int x) {
switch (x) {
case 0:
return x;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment