【发布时间】:2018-09-04 12:40:26
【问题描述】:
public Email myMethod(Function<MyObject, String>... functions) { ... }
我创建了一个函数列表,我想传递给 myMethod:
List<Function<MyObject, String>> functions= new ArrayList<>();
if (condition1) {
functions.add(myObject->myObject.getStringX());
} else {
functions.add(myObject->myObject.getStringY());
}
myMethod(functions);//Does not compile, I must find a solution here
to convert my list of functions to an array that can be accepted as
myMethod argument
【问题讨论】: