SHOW:
|
|
- or go back to the newest paste.
| 1 | - | function _G.typeCheck(value, expectedType, functionName) |
| 1 | + | local utils = {}
|
| 2 | - | if type(value) ~= expectedType then |
| 2 | + | |
| 3 | - | error("TypeError in " .. functionName .. ": Expected a " .. expectedType .. ", but received type '" .. type(value) .. "'.", 2)
|
| 3 | + | function utils.inList(value, list) |
| 4 | for index, listValue in ipairs(list) do | |
| 5 | if value == listValue then | |
| 6 | return true | |
| 7 | end | |
| 8 | - | function _G.findIndex(t, value) |
| 8 | + | |
| 9 | - | typeCheck(t, "table", "findIndex") |
| 9 | + | |
| 10 | - | typeCheck(value, "string", "findIndex") |
| 10 | + | |
| 11 | ||
| 12 | - | for i, v in ipairs(t) do |
| 12 | + | return utils |