lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 15.08.19 10:04, Sean Conner wrote:
>   Well ...
> 	complexLValue = @[#@ + 1] = newElement
>   -spc (Still looks weird ... )

yes looks weird, but this reminds my of another interesting and possible common
use case:

Chained assignment:
	a = b = c = expression;
would be equivalent to:
	local e = expression; a=e; b=e; c=e;

This would not imply that x = y is an expression. The chained assignment
statement would be a generalized case of normal assignment statement.

Example:
	local x =  complexLValue[y]
	if not x then
		x = {}
		complexLValue[y] = x
	end
	-- ... continue operating on x ...

With chained assignment:

		x = complexLValue[y] = {}

However this would only save one line in the above example.

-- Oliver