From d2b26fa6817285ea3bfc4c7220e2b622222862a4 Mon Sep 17 00:00:00 2001 From: rxi Date: Sun, 8 Feb 2015 15:12:57 +0000 Subject: [PATCH] Changed lume.clear() to return the table, updated doc & tests --- README.md | 3 ++- lume.lua | 1 + test/test_lume.lua | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 417299d..558740f 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,8 @@ lume.remove(t, 2) -- `t` becomes { 1, 3 } ``` ### lume.clear(t) -Nils all the values in the table `t`, this renders the table empty. +Nils all the values in the table `t`, this renders the table empty. Returns +`t`. ```lua local t = { 1, 2, 3 } lume.clear(t) -- `t` becomes {} diff --git a/lume.lua b/lume.lua index 6edd847..eed4927 100644 --- a/lume.lua +++ b/lume.lua @@ -180,6 +180,7 @@ function lume.clear(t) for k, v in iter(t) do t[k] = nil end + return t end diff --git a/test/test_lume.lua b/test/test_lume.lua index b30bb42..392cb0b 100644 --- a/test/test_lume.lua +++ b/test/test_lume.lua @@ -142,6 +142,7 @@ tests["lume.clear"] = function() local m = { a = 1, b = 2, c = 3 } lume.clear(m) testeq(m, {}) + testeq( lume.clear(t) == t, true ) end -- lume.shuffle