【发布时间】:2022-10-13 17:11:50
【问题描述】:
如果在下面的生成函数中没有任何用途,为什么我需要声明一个名为“idx”的 int 类型变量?
Random r2 = new Random();
var list = List<int>.generate(5, (int idx) => r2.nextInt(100));
如果我不声明它飞镖会给我以下错误
The argument type 'int Function()' can't be assigned to the parameter type 'int Function(int)'
【问题讨论】: