Properties and std.container.Array

Frustrated c1514843 at drdrb.com
Thu Jan 9 04:15:30 PST 2014


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
> {
> std.container.Array!int _arr;
> @property std.container.Array!int arr() { return _arr; }
> @property std.container.Array!int arr(std.container.Array!int 
> a) {_arr = a; return _arr; }
> }
>
> if I use _arr directly then everything works.
>
> Why are properties screwing up std.container.Array?

I should also mention that if I simply assign the arr property to 
a local variable before I use it everything works but this is not 
the way things should work.


More information about the Digitalmars-d-learn mailing list