D and a bazillion of small objects
Simen kjaeraas
simen.kjaras at gmail.com
Wed Jun 2 18:04:53 PDT 2010
Yao G. <nospamyao at gmail.com> wrote:
> Thanks bearophile.
>
> With respect to passing structs as reference, I also have this problem.
> In the widget, I have a opIndex method, that returns a ListViewItem
> given an index (like an array). When opIndex return the instance I'm
> looking for, and then I modify some property (a image index, for
> example) the change is only visible in the returned copy, but the
> internal instance, the one stored in the collection (array in this case)
> is not modified.
So use a ref return.
ref T opIndex( int index ) {
return arr[index];
}
--
Simen
More information about the Digitalmars-d-learn
mailing list