On 02-09-2012 17:05, Tyro[17] wrote:
On 9/2/12 11:45 PM, Andrei Alexandrescu wrote:
On 9/2/12 4:22 PM, Andrei Alexandrescu wrote:
[snip]

The alternative would be to simply define these as functions:

if (a.among("struct", "class", "union")) { ... }
if (b.between(1, 100)) { ... }


Andrei

if (a in ["struct", "class", "union"]) { ... }
if (a in someArrayVar) { ... }

works wonders for me. Why not? Somehow I cannot see the disadvantages.
Please educate.

Andrew

The argument seems to be that since an array search is O(n) and an AA lookup is O(1), this example would be "misleading".

Not that I think this matters at all in practice.

--
Alex Rønne Petersen
[email protected]
http://lycus.org

Reply via email to