works:programmer:lua:index

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
works:programmer:lua:index [2020/02/12 15:07]
Chugreev Eugene
works:programmer:lua:index [2022/06/21 09:46] (current)
Chugreev Eugene
Line 1: Line 1:
 ====== Язык программирования LUA ====== ====== Язык программирования LUA ======
 +  * [[works:programmer:lua:snipets]]
   * [[works:programmer:lua:classes]]   * [[works:programmer:lua:classes]]
 +  * [[works:programmer:lua:json]]
   * [[works:programmer:lua:comma-and-dot]]   * [[works:programmer:lua:comma-and-dot]]
   * [[works:programmer:lua:linq]]   * [[works:programmer:lua:linq]]
 +  * [[works:programmer:lua:dump]]
 +  * [[works:programmer:lua:pack-unpack]]
 +  * [[works:programmer:lua:strings]]
 +  * [[works:programmer:lua:cache-class]]
  
- 
- 
-===== Сделать простой дамп таблицы ===== 
-<code=lua> 
-function dump(var) 
-    local res = "" 
-    if type(var) == "string" then 
-        return '"' .. var .. '"' 
-    elseif type(var) == "number" then 
-        return "" .. var 
-    elseif type(var) == "function" then 
-        return '@' 
-    elseif type(var) == "boolean" then 
-        if var then 
-            return "true" 
-        else 
-            return "false" 
-        end 
-    elseif type(var) == "nil" then 
-        return nil 
-    elseif type(var) == "table" then 
-        -- ipairs   - indexed pairs 
-        -- pairs    - key named pairs 
-        res = "{" 
-        if not indexed then 
-            for k, v in pairs(var) do 
-                res = res .. dump(k) .. '=' .. dump(v) .. ',' 
-            end 
-        end 
-        res = string.sub(res, 1, string.len(res)-1) 
-        res = res .. "}" 
-    else 
-        print(type(var)) 
-    end 
-    return res 
-end 
- 
-local socket = {my="test",table="example", "1", "2", "3"} 
-print(dump(socket)) 
-</code> 
  
works/programmer/lua/index.1581520076.txt.gz · Last modified: 2020/02/12 15:07 by Chugreev Eugene