Never use print() to debug again. (lua)
lua version of IceCraem.
luarocks install icecream-lua
improt 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 exmple of printing function
local function fun1(a)
return a + 1
end
ic(fun1(22))
output ic| fun1(22) = 23
The exmple 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 exmple when there is no variable name
ic(1, 2)
output: ic| 1, 2
The exmple of display line munber
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 = 1