Same idea as my previous question, just a little more advanced. I want to write the following Scala code in Java:
Option(System.getProperty("not.present")).orElse(Some("default")).get
I tried this:
final Function0<Option<String>> elseOption = new Function0<Option<String>>() {
@Override public Option<String> apply() {
return new Some<String>("default");
}
};
final Option<String> notPresent =
new Some<String>(System.getProperty("not.present")).
orElse(elseOption).get();
But I get:
<anonymous OptionDemo$1> is not abstract and does not override abstract method apply$mcD$sp() in scala.Function0
[error] orElse(new Function0<Option<String>>() {