NI
nirokay/Lua-Utils
A collection of libraries/modules to ease your coding life with Lua. :)
Lua-Utils
A collection of libraries/modules to ease your coding life with Lua. :)
Feel free to use and or modify the code for your own projects.
In this collection
Switch
This is an implementation of the Switch/case statement written for Lua, as it
does not have its own switch/case out of the box.
Usage:
require("Switch") -- import the module
local switch = Switch.switch -- optional but recommended for better code readability
local name = "Peter"
switch(name, {
-- This function will not be run, as name does not equal 'Judy':
['Judy'] = function()
print(name .. " is very nice.")
end,
-- This function will be run, as name matches 'Peter':
['Peter'] = function()
print(name .. " is very polite.")
end,
-- This function will be run if no matches were found:
['default'] = function()
print(name .. " wasn't found :(")
end
})On this page
Languages
Lua100.0%
Contributors
GNU General Public License v3.0
Created May 10, 2022
Updated December 11, 2025
