Lua idioms compiled in one place

2k Views Asked by At

I am using Lua for some of my apps. I am looking for a central repository of Lua idioms because I don't want to write C in Lua.

A few examples I've come across are:

x = x or v

This sets a default value for x if it is not already set.

Another is

x, y = y, x

to exchange two variables.

3

There are 3 best solutions below

0
On BEST ANSWER

There are a whole bunch of useful snippets and idioms in these links:

http://lua-users.org/wiki/SampleCode

http://www.luafaq.org

2
On

Try http://lua-users.org/wiki/LuaDirectory - that and the Lua manual/PiL are probably your two best resources in this regard.

3
On

Lua Patterns, Tips and Tricks here on Stack Overflow is also very good read.