我们应该如何称呼存储该功能接口的实现的对象呢?将其称为匿名类是否正确?
功能接口定义
@FunctionalInterface
interface IntBinaryOperator {
int applyAsInt(int left, int right);
}
Run Code Online (Sandbox Code Playgroud)
用于实现功能接口的测试类
public class Lambdas {
public static void main(String[] args) {
IntBinaryOperator multiply = (a, b) -> a * b; // what is this object called?
System.out.println(multiply.applyAsInt(2,3));
}
}
Run Code Online (Sandbox Code Playgroud) 我这里有这个代码。
fn main() {
// Assign a reference of type `i32`. The `&` signifies there
// is a reference being assigned.
let reference = &4;
match reference {
val => println!("Got a value via destructuring: {}", val),
}
match *reference {
val => println!("Got a value via destructuring: {}", val),
}
}
Run Code Online (Sandbox Code Playgroud)
我期待得到这样的结果:
Got a value via destructuring: &4
Got a value via destructuring: 4
Run Code Online (Sandbox Code Playgroud)
但我得到了
Got a value via destructuring: 4
Got a value via destructuring: 4
Run Code Online (Sandbox Code Playgroud)
有人可以解释一下这是怎么回事吗?
假设我有\nvoid (*ptr[3])(int) \n并且\nvoid (*ptr)[3](int)
第一个按预期工作。\n但第二个抛出错误。
\n我尝试了这两种方法,但无法找出问题所在。\n错误内容如下:
\n\n\n“..错误:将 \xe2\x80\x98ptr\xe2\x80\x99 声明为函数数组 void\n(*ptr)3;”
\n