Modul:Common: Unterschied zwischen den Versionen

keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
Zeile 79: Zeile 79:
function isEmpty(a)
function isEmpty(a)
return a == '' or a == nil
return a == '' or a == nil
end
function len(t)
    -- Überprüfe, ob es ein String ist
    if type(t) == "string" then
        local count = 0
        -- Zähle jedes Zeichen im String
        for _ in string.gmatch(t, ".") do
            count = count + 1
        end
        return count
    -- Überprüfe, ob es eine Tabelle ist
    elseif type(t) == "table" then
        local count = 0
        for _ in pairs(t) do
            count = count + 1
        end
        return count
    else
        return nil  -- Falls der Typ nicht unterstützt wird
    end
end
end