0
나는 이런 식으로 보입니다.메소드 참조가이 기능과 작동하지 않는 이유는 무엇입니까?
static <R> R applyOthers(Some some, Function<List<Other>, R> function) {
List<Other> others = ...;
return function.appply(others);
}
지금 내가이 때,
withSome(some -> {
List<Other> others1 = applyOthers(some, v -> v); // works
List<Other> others2 = applyOthers(some, Function::identity); // doesn't
});
오류, 내가 얻을.
incompatible types: unexpected static method <T>identity() found in unbound lookup
where T is a type variable:
T extends Object declared in method <T>identity()
왜 ::identity
이 작동하지 않습니까?
그게 다예요! 'Function :: identity'가 아닌'Function.identity()'이어야합니다. 감사. –