Modul:Common: Unterschied zwischen den Versionen

tableConcatNil() + nil Handling
(+ tableConcatNil())
(tableConcatNil() + nil Handling)
Zeile 142: Zeile 142:
-- Default sep ist " "
-- Default sep ist " "
-- {nil, 2, nil, 4, nil, ["a"]="b"} wird zu "2 4"
-- {nil, 2, nil, 4, nil, ["a"]="b"} wird zu "2 4"
local s = ""
local s
-- höchsten Index ermitteln
if t ~= nil then
local i_max = 0
s = ""
for i, _ in pairs(t) do
-- höchsten Index ermitteln
if type(i) == "number" and i > i_max then
local i_max = 0
i_max = i
for i, _ in pairs(t) do
if type(i) == "number" and i > i_max then
i_max = i
end
end
end
end
-- alle Indizes durchiterieren
-- alle Indizes durchiterieren
for i = 1, i_max do
for i = 1, i_max do
if not p.isEmpty(t[i]) then
if not p.isEmpty(t[i]) then
if s ~= "" then
if s ~= "" then
s = s .. (sep or " ")
s = s .. (sep or " ")
end
s = s .. t[i]
end
end
s = s .. t[i]
end
end
end
end