Skip to content

Instantly share code, notes, and snippets.

@lukecampbell
Created July 26, 2012 16:58
Show Gist options
  • Save lukecampbell/3183219 to your computer and use it in GitHub Desktop.
Save lukecampbell/3183219 to your computer and use it in GitHub Desktop.
Example of Java's short circuitness
(work)Lukes-ASA-Macbook:tmp luke$ javac ShortCircuit.java
(work)Lukes-ASA-Macbook:tmp luke$ java ShortCircuit
Mind Blown
public class ShortCircuit
{
public static boolean do_something()
{
System.out.println("You shouldn't see this.");
return true;
}
public static void main(String[] args)
{
if(false && do_something())
{
System.out.println("You really shouldn't see this.");
}
System.out.println("Mind Blown\n");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment