Never use print() to debug again. (lua)
lua version of IceCream.
luarocks install icecream-luaimport module:
local ic = require("icecream")just use ic() to print information
The example of printing variables
a = 10
ic(a)
local x = 1
local y = 2
ic(x,y)output ic| a = 1 and ic| x = 1, y = 1
The example of printing function
local function fun1(a)
return a + 1
end
ic(fun1(22))output ic| fun1(22) = 23
The example when there are no parameters
ic()output: ic| + filename + line + function, like this: ic| /home/wlz/gh/icecream-lua/main.lua:37: in local 'testNoArg'
The example when there is no variable name
ic(1, 2)output: ic| 1, 2
The example of display line number
ic(x,y)
-- ic| x = 1, y = 1
ic:SetIsOutPutPosition(true)
ic(x,y)
-- /home/wlz/gh/icecream-lua/main.lua:11: in local 'testPosition'
-- ic| x = 1, y = 1Example of enabling and disabling print
local x = 1
local y = 2
local z = 3
ic:Disable()
ic(x)
ic(y)
ic:Enable()
ic(z)
-- ic| z = 3