Function types versus arrays
Howard Lovatt
howard.lovatt at iee.org
Thu Feb 18 02:17:32 PST 2010
Hi John,
Your examples in:
http://www.artima.com/weblogs/viewpost.jsp?thread=278567
Are:
// hard to infer A/T, must return concrete #(Object x)(x)
// static <T, A extends T> #T(A) identityFunction() { return #(A x)(x); }
static <T, A extends T> _Callable_1<T, A> identityFunction() {
return new _Callable_1<T, A>() {
@Override public T call(A x) { return x; }
};
}
// Don't really understand this - what does type.cast does? However,
don't need typecast for constantFunction.
// static <T> #T() constantFunction(T x) { return type.cast( #()(x) ); }
static <T> _Callable_0<T> constantFunction(final T x) {
return new _Callable_0<T>() {
@Override public T call() { return x; }
};
}
-- Howard.
More information about the lambda-dev
mailing list