Skip to content

Commit

Permalink
Bring table.is_empty() error message up to standard
Browse files Browse the repository at this point in the history
  • Loading branch information
vadi2 committed Sep 15, 2019
1 parent 5192968 commit fa09e20
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
8 changes: 1 addition & 7 deletions src/mudlet-lua/lua/DB.lua
Expand Up @@ -21,13 +21,7 @@ if not string.trim then
require "StringUtils"
end

-- TODO those funciton are already definde elsewhere
-- Tests if a table is empty: this is useful in situations where you find
-- yourself wanting to do 'if my_table == {}' and such.
function table.is_empty(tbl)
return next(tbl) == nil
end

-- TODO those functions are already definde elsewhere
function string.starts(String, Start)
return string.sub(String, 1, string.len(Start)) == Start
end
Expand Down
5 changes: 2 additions & 3 deletions src/mudlet-lua/lua/TableUtils.lua
Expand Up @@ -14,9 +14,8 @@
--- end
--- </pre>
function table.is_empty(tbl)
if next(tbl) == nil then
return true else return false
end
assert(type(tbl) == "table", string.format("bad argument #1 type (table expected, got %s!)", type(currentValue)))
return next(tbl) == nil
end

-- The filter() method creates a new table with all elements that pass the test
Expand Down

0 comments on commit fa09e20

Please sign in to comment.