June 15, 2004 arrays with non-int indexes | ||||
---|---|---|---|---|
| ||||
I didn't dare hope that this would compile class A { float opIndex(float k) { return k; } float opIndex(float k, float v) { return k; } } I have to say that this is cool! If at some point in the future I can also do e.g. class A { float opIndex(float k1, float k2, float k3) { ... } float opIndex(float k1, float k2, float k3, float v) { ... } ... } That'll be awesome! Not to speak of slicing... |
June 16, 2004 Re: arrays with non-int indexes | ||||
---|---|---|---|---|
| ||||
Posted in reply to Bent Rasmussen | Bent Rasmussen wrote:
> I didn't dare hope that this would compile
>
> class A
> {
> float opIndex(float k) {
> return k;
> }
> float opIndex(float k, float v) {
> return k;
> }
> }
Actually, after the recent introduction of opIndexAssign, this will have to be:
class A
{
float opIndex(float k) {
return k;
}
float opIndexAssign(float v, float k) {
return k;
}
}
(Not sure about the final resolution about the ordering of the arguments.)
|
Copyright © 1999-2021 by the D Language Foundation