Skip to content

nirokay/Lua-Utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
})

Switch Statement Picture

About

A collection of libraries/modules to ease your coding life with Lua. :)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages