是否可以以编程方式读取lambda引用的类和静态方法名称?例如:
R version 3.3.0 (2016-05-03)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] rworldmap_1.3-6 sp_1.2-3 RSQLite_1.0.0 DBI_0.4-1
loaded via a namespace (and not attached):
[1] foreign_0.8-66 fields_8.4-1 maps_3.1.0 maptools_0.8-39
[5] grid_3.3.0 spam_1.3-0 lattice_0.20-33
我想以某种方式阅读R version 3.1.1 (2014-07-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] rworldmap_1.3-6 sp_1.0-15 RSQLite_0.11.4 DBI_0.3.1
loaded via a namespace (and not attached):
[1] fields_8.3-6 foreign_0.8-61 grid_3.1.1 lattice_0.20-29
[5] maps_2.3-9 maptools_0.8-30 spam_1.3-0
指向public class Testing {
interface Generic { void call(); }
static public void method1() {
System.out.println("In method1");
}
static public void method2() {
System.out.println("In method2");
}
public void test() {
Generic g1 = () -> Testing.method1();
Generic g2 = () -> Testing.method2();
g1.call();
g2.call();
// System.out.println("g1 -> " + getLambdaReference(g1))
}
而g1
指向Testing.method1
。
答案 0 :(得分:0)
没有这样的参考。那些lambda函数只是执行一些代码的Lambdas。
如果这些方法可行,那么你如何处理
Generics g = ()->1+2;
或任何其他只是表达式?