Thread overview | |||||
---|---|---|---|---|---|
|
September 11, 2010 opIndex() overloading for multiple arrays | ||||
---|---|---|---|---|
| ||||
Hey guys, is it possible to overload opIndex() with a multiple array, for example: class Example { ... char[] opIndex(uint index1, uint index2) { return "my text to return"; } ... } Example t = new Example(); writefln(t[0][10]); Looking forward to hearing from anyone :) |
September 11, 2010 Re: opIndex() overloading for multiple arrays | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nrgyzer | On Sat, 11 Sep 2010 15:30:33 +0200, Nrgyzer <Nrgyzer@gmail.com> wrote: > Hey guys, > > is it possible to overload opIndex() with a multiple array, for > example: > > class Example { > ... > char[] opIndex(uint index1, uint index2) { > return "my text to return"; > } > ... > } > > Example t = new Example(); > writefln(t[0][10]); > > Looking forward to hearing from anyone :) Exactly what you did, only you need to index it differently: writeln( t[0,10] ); http://www.digitalmars.com/d/2.0/operatoroverloading.html#Array -- Simen |
September 11, 2010 Re: opIndex() overloading for multiple arrays | ||||
---|---|---|---|---|
| ||||
Posted in reply to Simen kjaeraas | Thanks for reply... exactly, what I need. |
Copyright © 1999-2021 by the D Language Foundation