array.length++ not an lvalue

Lutger lutger.blijdestin at gmail.com
Wed Jun 18 06:28:19 PDT 2008


Erik Lechak wrote:

...
> For what it's worth, I think 'array'.length++ and 'array'.length += 1
> should be valid.  If that is not an option, it would be nice if the error
> message could be changed to something like "Error: x.length is a special
> property that prohibits the use of the increment (++) and add_and_assign
> (+=) operators".
> 
> Thanks,
> Erik Lechak

All properties behave like that, it's mentioned in the spec:

"Note: Properties currently cannot be the lvalue of an op=, ++, or --
operator."


In between the spec and the wiki4d, everything can be found but I'm not
aware of any site that has a list of common pitfalls specifically, except
yours of course...





More information about the Digitalmars-d mailing list