Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat
New Lua enhancements - Gideros Forum

New Lua enhancements

SinisterSoftSinisterSoft Maintainer
edited October 2017 in Code snippets
I've added a multi-dimensional array indexing with comma syntax patch by Mark Fieldman.

It modifies the parser to support multi-dimensional array indexing with comma syntax, i.e. m[1,2] is treated by the parser as being identical to m[1][2], thus allowing for code such as the following:
m = {[1]={}, [2]="foo"}
m[1,2] = "bar"
print(m[2], m[1][2], m[1,2])  --> foo  bar bar
m.foo = {}
m.foo.bar = "baz"
print(m["foo","bar"])         --> baz
I've also added some mutation operators:

+= add
-= sub
*= mult
/= div
%= mod
^= power
a+=1 -- a is now 5
a^=2 -- a is now 25
These will save a lot of typing and should be faster because the source variable only needs to be looked up once.
+1 -1 (+4 / -0 ) Share on Facebook


Sign In or Register to comment.