Why is array.reverse a property and not a method?

eris jvburnes at gmail.com
Mon Jul 12 09:16:32 PDT 2010


Just though I'd post here on something that made me question my sanity late
one night.

I was working on some test code and for some reason put parens around
"myArray.reverse".  After that the compiler complained that "reverse" was an
unknown identifier.  It took me about 30 minutes at 2am to finally give up and
figure out I needed sleep.

The next morning after some google searching I noticed that everyone was
referring to the 'reverse' "property".  That caught my eye.  reverse property?
 Thats not a property, it's a method -- especially since it does an in-place
modification of the object.

This must mean it's something I don't understand.  The only thing I could
think of is that the "reverse" property is actually a boolean which tells the
iterator which direction to traverse the data structure.

Your thought are appreciated.



More information about the Digitalmars-d mailing list