We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 62dae8a commit efb3509Copy full SHA for efb3509
3 files changed
spec/List_spec.lua
@@ -90,6 +90,8 @@ describe("mods.List", function()
90
{ "insert" , abc__ , { "d" } , abcd_ , true },
91
{ "intersection" , a_c_e , { _bcd_ } , __c__ , false },
92
{ "invert" , a___e , { } , a1_e2 , false },
93
+ { "isempty" , _____ , { } , true , },
94
+ { "isempty" , abc__ , { } , false , },
95
{ "join" , abc__ , { "," } , "a,b,c" , },
96
{ "join" , abcde , { } , "abcde" , },
97
{ "keypath" , abc__ , { } , "a.b.c" , },
@@ -126,7 +128,6 @@ describe("mods.List", function()
126
128
{ "tostring" , a___e , { } , '{ "a", "e" }' , },
127
129
{ "uniq" , AZAZA , { } , AZ___ , false },
130
{ "zip" , abc__ , { _12__ } , { a1, b2 } , false },
- { "join" , ____e , { } , 'e' , },
131
132
-- Cases where the second argument is provided as a Set.
133
{ "difference" , a_c_e , { Set(_bcd_) } , a___e , false },
src/mods/List.lua
@@ -294,6 +294,10 @@ function List:len()
294
return #self
295
end
296
297
+function List:isempty()
298
+ return #self == 0
299
+end
300
+
301
function List:lt(ls)
302
return lex_cmp(self, ls) == -1
303
types/List.lua
@@ -406,6 +406,18 @@ function List:index_if(pred) end
406
---@nodiscard
407
function List:len() end
408
409
+---
410
+---Return whether the list has no elements.
411
412
+---```lua
413
+---ok = List():isempty() --> true
414
+---```
415
416
+---@param self mods.List|any[] Current list.
417
+---@return boolean empty `true` when the list has no elements.
418
+---@nodiscard
419
+function List:isempty() end
420
421
--------------------------------------------------------------------------------
422
------------------------------------ Access ------------------------------------
423
0 commit comments