github.com/arnodel/golua@v0.0.0-20230215163904-e0b5347eaaa1/runtime/lua/miscops.lua (about) 1 do 2 print(#"abc") 3 --> =3 4 5 local t = {1, 2} 6 7 print(#t) 8 --> =2 9 10 local f = function() return 3 end 11 setmetatable(t, {__len=function() return f() end}) 12 13 print(#t) 14 --> =3 15 16 f = function() error("hi", 0) end 17 print(pcall(function() return #t end)) 18 --> =false hi 19 20 print(pcall(function() return #1 end)) 21 --> ~^false\t 22 end 23 24 do 25 print(type"abc", type{}, type(true), type(1), type(function() end)) 26 --> =string table boolean number function 27 28 local t = coroutine.create(function() end) 29 print(type(t)) 30 --> =thread 31 32 print(type(nil)) 33 --> =nil 34 35 print(type(io.stdout)) 36 --> =userdata 37 38 print(io.type(io.stdout)) 39 --> =file 40 end