0

From here: http://functionaljava.googlecode.com/svn/artifacts/3.0/demo/bgga/Option_filter.java

Q: Ho would I compile this example? If no way: What the purpose to put now working examples?

import fj.data.Option;
import static fj.data.Option.none;
import static fj.data.Option.some;
import static fj.Show.intShow;
import static fj.Show.optionShow;

public final class Option_filter {
  public static void main(final String[] args) {
    final Option<Integer> o1 = some(7);
    final Option<Integer> o2 = none();
    final Option<Integer> o3 = some(8);
    final Option<Integer> p1 = o1.filter({int i => i % 2 == 0});
    final Option<Integer> p2 = o2.filter({int i => i % 2 == 0});
    final Option<Integer> p3 = o3.filter({int i => i % 2 == 0});
    optionShow(intShow).println(p1); // None
    optionShow(intShow).println(p2); // None
    optionShow(intShow).println(p3); // Some(8)
  }
}

I don't see any chance for Java (5-7) compile this, for example:

filter({int i => i % 2 == 0});
ses
  • 13,174
  • 31
  • 123
  • 226
  • Indeed, it doesn't compile in Java 7 (or earlier). I imagine this is what you're looking for: https://code.google.com/p/functionaljava/source/browse/artifacts/3.0/demo/1.5/Option_filter.java. – Oliver Charlesworth Mar 30 '14 at 17:13

1 Answers1

1

This example uses the proposed BGGA syntax. Java 8 code examples are at http://www.functionaljava.org/examples-java8.html. Your specific example is there and in the Github repo at https://github.com/functionaljava/functionaljava/blob/master/demo/src/main/java/fj/demo/Option_filter.java.

Your code is from the old repo and website. Please use the new site at www.functionaljava.org and at github on github.com/functionaljava/functionaljava.

Mark Perry
  • 1,656
  • 1
  • 9
  • 6