From c22d3381e7f78c91def0ce1991fef07763ca486b Mon Sep 17 00:00:00 2001 From: kikito Date: Mon, 15 Sep 2014 10:49:12 +0200 Subject: [PATCH] Fix process example in README --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index cd1ec88..238acbc 100644 --- a/README.md +++ b/README.md @@ -182,17 +182,17 @@ end assert(inspect(t, {process = remove_mt}) == "{ 1, 2, 3 }") ``` -The previous exaple only works for a particular metatable. If you want to make *all* metatables, you can use `path`: +The previous exaple only works for a particular metatable. If you want to make *all* metatables, you can use the `path` parameter to check +wether the last element is `inspect.METATABLE`, and return `nil` instead of the item: ``` lua local t, mt = ... -- (defined as before) local remove_all_metatables = function(item, path) - if path[#path] ~= '' then return item end + if path[#path] ~= inspect.METATABLE then return item end end --- Removes all metatables -assert(inspect(t, {process = remove_mt}) == "{ 1, 2, 3 }") +assert(inspect(t, {process = remove_all_metatables}) == "{ 1, 2, 3 }") ``` Filter a value: