小编pus*_*hpa的帖子

我们如何称呼存储功能接口定义并通过 lambda 定义的对象?

我们应该如何称呼存储该功能接口的实现的对象呢?将其称为匿名类是否正确?

功能接口定义

@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)

java lambda functional-programming functional-interface

1
推荐指数
1
解决办法
61
查看次数

显示参考文献

我这里有这个代码。

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)

有人可以解释一下这是怎么回事吗?

dereference rust

1
推荐指数
1
解决办法
44
查看次数

c中的`void *ptr[N](int)`和`void (*ptr)[N](int)`有什么区别?

假设我有\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
\n

c pointers function operator-precedence

0
推荐指数
1
解决办法
101
查看次数