foreach reference to struct variable
Prashant V
dmd at prashantv.com
Thu Feb 7 14:56:34 PST 2008
I wanted to use D for a simple program just to get a feel for how to use it, and while overall it was pretty easy, I found an annoying problem that I could not find an answer to online.
I want to be able to iterate through an array, and I want the current element to be the actual struct in the array itself. At the moment, it looks like the foreach is making a copy of the struct in the array so any changes are not made to the original in the array.
Is there any way to tell D to specifically give me the referenced variable rather than a copy? I had to resort to using for with an index, and I don't really think that is an ideal solution.
I want to know if there is a D syntax for the & reference modifier in C++.
More information about the Digitalmars-d
mailing list