On 01/18/2017 11:48 PM, Jot wrote:
alias a = myarray[k];
fails
myarray is a multidimensial array that I want to reduce writing it every
time but D complains that it can't alias it.
I simply want it to do a direct substitution, nothing fancy, just to
reducing typing.
Nested functions work pretty well in some cases:
import std.stdio;
void foo() {
int[double][char][string] aa;
aa["hello"]['b'][ 3.5] = 35;
auto a = "hello";
char b = 'b';
// Works like an alias:
ref theOne() {
return aa[a][b];
}
theOne[1.5] = 15;
theOne[2.5] = 25;
writeln(aa);
}
void main() {
foo();
}
Ali