github.com/arnodel/golua@v0.0.0-20230215163904-e0b5347eaaa1/runtime/lua/etc.lua (about) 1 do 2 local function f(...) 3 print(...) 4 end 5 f(1, 2) 6 --> =1 2 7 8 local function f(...) 9 local a, b, c = ..., ... 10 print(a, b, c) 11 end 12 f(1, 2, 3) 13 --> =1 1 2 14 15 f(1) 16 --> =1 1 nil 17 18 f() 19 --> =nil nil nil 20 end 21 22 do 23 local function c(t) 24 print(table.concat(t, '-')) 25 end 26 27 local function f(...) 28 c({...}) 29 c({"a", "b", ...}) 30 end 31 f(1, 2) 32 --> =1-2 33 --> =a-b-1-2 34 35 local function g() 36 return 3, 2, 1 37 end 38 c({g()}) 39 --> =3-2-1 40 41 c({1, 2, g()}) 42 --> =1-2-3-2-1 43 44 c({g(), g()}) 45 --> =3-3-2-1 46 end 47 48 do 49 local function f() 50 return 1, 2 51 end 52 53 print(f()) 54 --> =1 2 55 56 print((f())) 57 --> =1 58 59 local a, b = (f()) 60 print(b) 61 --> =nil 62 63 local t = {f()} 64 print(#t) 65 --> =2 66 67 t = {(f())} 68 print(#t) 69 --> =1 70 end