Please vote once and for good: range operations

bearophile bearophileHUGS at lycos.com
Wed Jan 28 23:39:21 PST 2009


Andrei Alexandrescu:
> Python:
> lst[0]
> lst[len(lst)-1]

I have not read the whole thread so someone else may have already answered, but that's not pythonic, the last item is represented as:

>>> lst = "abcde"
>>> lst[-1]
'e'
>>> lst[-2]
'd'

etc.

You can write those in D as:
lst[$-1]
lst[$-2]

Bye,
bearophile



More information about the Digitalmars-d mailing list