Lua’s syntactic.sugar

After implementing associative array support, it turns out I was four lines of code away from Lua’s cute getindex trick:

var d = dict()
d["i am text"] = "value1"
d[3] = "value2"
d["awesome"] = "value3"
print("output1: %s\n" % (d["i am text"]))
print("output2: %s\n" % (d[3]))
print("output3: %s\n" % (d.awesome))

Note the “d.awesome”. Yeah, that’s right.

Posted in Blog