Common Library

The common library is a simple Lua file that just includes several popular and highly used libraries all in one.

The common library also exposes a useful switch statement implementation that addons can use to mimic switch case statements that are available in other languages.

An example of the switch case function:

function get_container_name(id)
    return switch(tostring(id)) : caseof
    {
        ['0'] = function() return 'Inventory'; end
        ['1'] = function() return 'Mog Safe'; end,
        ['2'] = function() return 'Storage'; end,
        ['default'] = function() return nil; end,
    };
end
 
-- This should print 'Mog Safe'..
print(get_container_name(1));