Java has a feature called anonymous classes that works practically the same as object expressions in F#, and that's a pretty old feature, introduced even before Java 8 I think. Check some examples here.
Before Java 8, that feature was widely used to get something like lambda expressions, but with a tiny bit less terse syntax, like this:
interface MyFunctionLike {
int run();
}
MyFunctionLike aBitLikeLambda = new MyFunctionLike {
@Override
public int run() {
return 2 + 2;
}
};
The full analog in F# would be
type MyFunctionLike =
abstract member run: unit -> int
let aBitLikeLambda =
{ interface MyFunctionLike with
member _.run() = 2 + 2 }
So, the comment in question is inaccurate, and I suggest to avoid mentioning Java there.
Java has a feature called anonymous classes that works practically the same as object expressions in F#, and that's a pretty old feature, introduced even before Java 8 I think. Check some examples here.
Before Java 8, that feature was widely used to get something like lambda expressions, but with a tiny bit less terse syntax, like this:
The full analog in F# would be
So, the comment in question is inaccurate, and I suggest to avoid mentioning Java there.