[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: append to list operator
- From: Sean Conner <sean@...>
- Date: Thu, 15 Aug 2019 04:04:22 -0400
It was thus said that the Great Oliver once stated:
> On 13.08.19 06:45, Sean Conner wrote:
> > Well, another pain point is
> > veryLongNmae[complexLValue] = veryLongName[complexLValue] + 1
> a similar and common use case is appending an element to an array: it's also
> painful to write:
> complexLValue[#complexLValue + 1] = newElement;
> One can circumvent this by having a append function:
> append(complexLValue, newElement);
> but this makes the assignment not as visible as the first approach does.
> A solution for current official lua with explicit assignment:
> local list = complexLValue; list[#list + 1] = newElement;
> Can this be rewritten using the imaginary @ operator?
> complexLValue[#@ + 1] = newElement;
> Now the @ would be on the left side of the assignment, this looks weird.
complexLValue = @[#@ + 1] = newElement
-spc (Still looks weird ... )