elixirian · elixir · recipes · iex · helpers

Elixiran | Recipes | Recipe 2: IEx helpers

Let’s look at built-in IEx helpers which print docs about module, method, introspect data, type(s), reuse shell results.

In short - make our work efficient.


🍳 Recipe 2: The h, i, t, v helpers

The secret spice blend of IEx.

iex> h IExHelpers
# prints the doc

recipe 2, 1: `h()` for docs


iex> some = "TEST"
iex> i some
# full introspection

recipe 2, 2: `i()` to introspect


iex> t Enum
# view the types defined

recipe 2, 3: `t()` to get type information


iex> v()
# see the value of the last

iex>v N
# or previous results (N is number of line, check screenshot)

recipe 2, 4: `v()` in iex to get previous result


💡 Pro Tip: since v() returns previous result - You can run reuse it

iex(1)> ["iex_helpers.ex", ".iex.exs", "screenshots"]
iex(2)>
nil
iex(3)>
nil
iex(4)> files = v(1)
["iex_helpers.ex", ".iex.exs", "screenshots"]
iex(5)> files |> Enum.each(& IO.puts("File: " <> &1))

recipe 2, 5: `v()` in iex to reuse previous result