Lua Coding Tips

This is a guideline for best practices when writing Lua code.

Avoid using globals

 * References: WowAce coding tips

Try to use local variables whenever possible. Ideally an addon should use only a single unique global. For instance, the global variable  is written and read by more than a hundred addons.

Replace getglobal
Use  instead of the deprecated getglobal

Checking if something exists
Any value other than  and   is truthy. Similarly, use the  operator unless you want to explicitly check for   or.