在模块内创建 dup 函数 - 与数组的 dup 属性 冲突
Creating a dup function inside a module - clashes with dup property of array
如果我在我的 D 程序中创建一个 dup
函数,我就不能再使用数组的 dup
属性。此代码有效
import std.stdio;
void main() {
double[] v = [0.1, 0.2, 0.3];
writeln(v.dup);
}
但是这段代码returns"clash.d(9): Error: function clash.dup (double x) is not callable using argument types (double[])"
import std.stdio;
double dup(double x) {
return x;
}
void main() {
double[] v = [0.1, 0.2, 0.3];
writeln(v.dup);
}
如何在我的程序中定义一个 dup
函数而不丢失数组的 dup
属性?
alias
它进入本地重载集:
alias dup = object.dup;
就在您自己的 dup
函数定义下方。
如果我在我的 D 程序中创建一个 dup
函数,我就不能再使用数组的 dup
属性。此代码有效
import std.stdio;
void main() {
double[] v = [0.1, 0.2, 0.3];
writeln(v.dup);
}
但是这段代码returns"clash.d(9): Error: function clash.dup (double x) is not callable using argument types (double[])"
import std.stdio;
double dup(double x) {
return x;
}
void main() {
double[] v = [0.1, 0.2, 0.3];
writeln(v.dup);
}
如何在我的程序中定义一个 dup
函数而不丢失数组的 dup
属性?
alias
它进入本地重载集:
alias dup = object.dup;
就在您自己的 dup
函数定义下方。