Hello Sam !
First of all thanks for commenting !
I didn't tried something like this
before so I wrote this small program and tried to compile/run:
====
var val = 3;
var tab = [1,2];
tab[++#tab] = val;
====
Output:
====
ljs: test-pp.ljs:3: unexpected symbol
near '#'
====
But it works this way showing a bug ?:
====
var val = 3;
var tab = [1,2];
tab[++(#tab)] = val;
====
Output:
====
ljs test-pp.ljs
1 1
2 3
====
The way it's implemented right now
reject it, but a way I usually use it in situations like this is
as follow:
====
var tab = {"one": 1, "two" : 2,
"three": 3, "four": 4};
var ary = [];
var idx = 0;
for(k,v in pairs(tab)) ary[++idx] = [k,v];
table.sort(ary, function(a,b){ return a[2] < b[2];});
for( idx, v in ipairs(ary)) print(idx, v[1], v[2]);
====
Output:
====
ljs test-pp2.ljs
1 one 1
2 two 2
3 three 3
4 four 4
===
I appreciate your comments.
Again thanks in advance for your time
and attention !
On 05/12/2018 21:16, Sam Putman wrote:
[
Hello !
I've updated the repositories with fixes for compound
operators on upvalues and also added pre/pos increment
operators "++/--".
If you don't mind my asking, what does this do?
tab[++#tab] = val
let's say #tab was 3, what happens?