IceCream (Ice Cream v0.0.5) View Source
Link to this section Summary
Functions
Prints the calling filename, line number, and parent module/function. It returns an :ok
atom.
Prints the term with itself as a label. Returns the evaluated term.
Link to this section Functions
Prints the calling filename, line number, and parent module/function. It returns an :ok
atom.
# lib/foo.ex
defmodule Foo do
import IceCream
def bar do
ic()
end
end
# running Foo.bar()
Foo.bar() # ic| lib/foo.ex:5 in Elixir.Foo.bar/0
:ok
Prints the term with itself as a label. Returns the evaluated term.
Examples
Variables
foo = "abc"
ic(foo) # ic| foo: "abc"
"abc"
Module Function Argument calls
ic(:math.pow(2,3)) # ic| :math.pow(2,3): 8.0
8.0
It also works with pipes
2
|> :math.pow(3)
|> ic() # ic| :math.pow(2,3): 8.0`
8.0
Options
Accepts the same options as the Inspect protocol. (see: Inspect.Opts
), with some additions:
:location
- when truthy, will add the file name and line number.:function
- when truthy, will print out the module name with the function name and arity.
# lib/foo.ex
defmodule Foo do
import IceCream
def bar(baz) do
ic(baz, location: true, function: true)
end
end
# running Foo.bar()
Foo.bar(1.0) # ic| lib/foo.ex:5 in Elixir.Foo.bar/1 baz: 1.0
1.0