www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Tokens

reply Justin Allen Parrott <erartqr gmail.com> writes:
I don’t like [$-1], I want to define a token L to be $-1 and use 
o[L]
May 12
parent =?UTF-8?Q?Ali_=C3=87ehreli?= <acehreli yahoo.com> writes:
On 5/12/25 12:10 AM, Justin Allen Parrott wrote:
 I don’t like [$-1], I want to define a token L to be $-1 and use o[L]
I like o.back: import std.range; void main() { int[] o = [ 1, 2, 3 ]; assert(o[$-1] == o.back); assert(&(o[$-1]) == &(o.back)); } Ali
May 12