I've tried insert, indexing, ~=, etc but the length always
returns 0.
e.g.,
std.container.Array!int arr;
arr ~= 3;
writeln(arr.length);
works fine, but when the array is a property of a class, it does
not work, e.g.,
class x
{
std.container.Array!int _arr;
@property std.container.Array!int
On Thursday, 9 January 2014 at 12:13:14 UTC, Frustrated wrote:
I've tried insert, indexing, ~=, etc but the length always
returns 0.
e.g.,
std.container.Array!int arr;
arr ~= 3;
writeln(arr.length);
works fine, but when the array is a property of a class, it
does not work, e.g.,
class x
{
On Thursday, 9 January 2014 at 12:15:31 UTC, Frustrated wrote:
On Thursday, 9 January 2014 at 12:13:14 UTC, Frustrated wrote:
I've tried insert, indexing, ~=, etc but the length always
returns 0.
e.g.,
std.container.Array!int arr;
arr ~= 3;
writeln(arr.length);
works fine, but when the array
On Thursday, 9 January 2014 at 12:19:25 UTC, Frustrated wrote:
I guess I see what is going on. Since Array is a struct, a
local copy is made and that never ends up updating the original?
How can I use it then like an object so this is not a problem?
returning by ref may do what you want:
@pr
On Thursday, 9 January 2014 at 13:32:08 UTC, Dicebot wrote:
On Thursday, 9 January 2014 at 12:19:25 UTC, Frustrated wrote:
I guess I see what is going on. Since Array is a struct, a
local copy is made and that never ends up updating the
original?
How can I use it then like an object so this i
On Thursday, 9 January 2014 at 14:51:33 UTC, monarch_dodra wrote:
On Thursday, 9 January 2014 at 13:32:08 UTC, Dicebot wrote:
On Thursday, 9 January 2014 at 12:19:25 UTC, Frustrated wrote:
I guess I see what is going on. Since Array is a struct, a
local copy is made and that never ends up updat
I think maybe using alias this would not solve the problem? One
would have to dispatch all the calls on the class to the array.
(simply wrap the struct but prevent the compiler from thinking it
is a strut so it doesn't use value semantics on it)