summaryrefslogtreecommitdiff
path: root/demo/Enum.lua
blob: d7fe469a9ff2e0d00ddf452758cee5300476d5e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
local Enum = function (enumStrings)
    local enumTable = {}
    for _,str in pairs(enumStrings) do
	enumTable[str] = str
    end

    local enum = {}
    setmetatable(enum, { __index = enumTable,
			 __newindex = function(table, key, value)
			     error('Attempt to edit enum!')
			 end
		       }
    )
    
    return enum
end

return Enum