Error: xxx is not an lvalue
Unknown W. Brackets
unknown at simplemachines.org
Sun May 3 02:25:09 PDT 2009
This code works fine (D 2.x only):
class Test
{
private int[int] _testMap;
public ref int[int] testMap() {return _testMap;}
}
void main()
{
Test test = new Test();
test.testMap[0] = 1;
}
Note the "ref". Otherwise, a value is returned which is not modifiable.
This will also fix test.array.length. Nothing wrong here, no creepy
bad temporary property problems.
I suppose you could also try returning a pointer to an associative array
(e.g. with &) in D 1.x.
-[Unknown]
flourish wrote:
> Hi,
>
> why does the following code not compile -- or how to declare a (usable)
> property of an associative array field?
>
> //////////////////////
> class Test
> {
> private int[int] _testMap;
> public int[int] testMap() {return _testMap;}
> }
>
>
> void main()
> {
> Test test = new Test();
> test.testMap[0] = 1;
> }
> /////////////////
>
> *** Error: test.testMap() is not an lvalue
>
>
> Regards,
> flourish
>
>
>
More information about the Digitalmars-d
mailing list