Skip to content

Commit

Permalink
update table lib with new function
Browse files Browse the repository at this point in the history
  • Loading branch information
notnotmelon committed Jun 17, 2024
1 parent 9fcf9b4 commit bd7573b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/table.lua
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@ end
---@param tbl table
---@return any
table.last = function(tbl)
local result
for _, v in pairs(tbl) do result = v end
return result
end

---Returns the last element of the array.
---@param tbl any[]
---@return any
table.array_last = function(tbl)
local size = #tbl
if size == 0 then return nil end
return tbl[size]
Expand Down

0 comments on commit bd7573b

Please sign in to comment.