DEV Community

Luis Gustavo Caciatori
Luis Gustavo Caciatori

Posted on

TIL IEX Console #1

TIL a small trick on Elixir console (iex) that is the helper i/1

When you type some piece of code on iex e.g:

iex(1)> IO.inspect {:a, :b}
{:a, :b}
Enter fullscreen mode Exit fullscreen mode

And after that you type i. This helper will print the type information about the last command typed on iex.

iex(1)> I
Term
  {:a, :b}
Data type
  Tuple
Reference modules
  Tuple
Implemented protocols
  IEx.Info, Inspect
Enter fullscreen mode Exit fullscreen mode

You also can specify a term to the helper as on the example below.

iex(3)> i (4 / 2)
Term
  2.0
Data type
  Float
Reference modules
  Float
Implemented protocols
  IEx.Info, Inspect, List.Chars, String.Chars

iex(4)> i "hello"
Term
  "hello"
Data type
  BitString
Byte size
  5
Description
  This is a string: a UTF-8 encoded binary. It's printed surrounded by
  "double quotes" because all UTF-8 encoded code points in it are printable.
Raw representation
  <<104, 101, 108, 108, 111>>
Reference modules
  String, :binary
Implemented protocols
  Collectable, IEx.Info, Inspect, List.Chars, String.Chars
Enter fullscreen mode Exit fullscreen mode

And that's it for today.

Top comments (0)