Skip to content

wlingze/icecream-lua

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IceCream-lua

Never use print() to debug again. (lua)

lua version of IceCream.

install

luarocks install icecream-lua

use

import 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 = 1