From 3b2282c96234f6f8c82d86f124d43c949b44688d Mon Sep 17 00:00:00 2001 From: Albert Krewinkel <albert@zeitkraut.de> Date: Wed, 27 Dec 2017 20:07:36 +0100 Subject: [PATCH] data/sample.lua: use `next` instead of for loop Each definition list item contains just a single key and the associated value. Using `next` to get the key/value pair is more idiomatic than iterating over the single-element table. --- data/sample.lua | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/data/sample.lua b/data/sample.lua index dd90af29d..6c09442b5 100644 --- a/data/sample.lua +++ b/data/sample.lua @@ -245,10 +245,9 @@ end function DefinitionList(items) local buffer = {} for _,item in pairs(items) do - for k, v in pairs(item) do - table.insert(buffer,"<dt>" .. k .. "</dt>\n<dd>" .. - table.concat(v,"</dd>\n<dd>") .. "</dd>") - end + local k, v = next(item) + table.insert(buffer, "<dt>" .. k .. "</dt>\n<dd>" .. + table.concat(v, "</dd>\n<dd>") .. "</dd>") end return "<dl>\n" .. table.concat(buffer, "\n") .. "\n</dl>" end