Negative indices for arrays

felix felix8a at
Fri Nov 12 13:52:40 PST 2010

the D language handles this by having the names '$' and 'length' be the 
length of the array, within the scope of a [] subscript, so you can say 
something like a[$-1].  '$' is already too widely used in js, but maybe 
something like '_' would work.  say, if there's no declaration of _ in 
scope, then _ within [] is the length of the array.

More information about the es-discuss mailing list