Skip to content

Instantly share code, notes, and snippets.

@wsoczynski
Created November 6, 2012 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wsoczynski/4025093 to your computer and use it in GitHub Desktop.
Save wsoczynski/4025093 to your computer and use it in GitHub Desktop.
Optional 2
class Main {
public Optional<String> someValue = Optional.absent();
public static void main(String... arguments){
Main m = new Main();
String foo = m.someValue.or("default value");
System.out.println(foo); //outputs "defaultValue"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment