On Saturday, 3 March 2012 at 16:50:45 UTC, bioinfornatics wrote:
> can w do same in D ?
alias this does that, although it does for all unknown
methods, not specific ones:
struct A {
int[] data;
alias data this;
}
A a;
a[0] = 10; // this works like a.data[0] = 10;
alias this also lets you pass the struct
when the member is expected:
void somethingWithArray(int[] arr) {}
A a;
somethingWithArray(a); // works, passes a.data automatically