Get the Previous Expression Value in IEx

When using Elixir, I’ve long missed the special _ helper from irb that returns the result of the previous expression. Sometimes I actually type it out of pure habit.

Little did I know that Elixir has the same thing, except better.

IEx.Helpers has a function v(n \\ -1) that returns the value of the nth expression in the session history. So v alone returns the previous expression and v(-2) returns the one before it.

iex(1)> "abc"
iex(2)> "zyx"
iex(3)> v
iex(4)> v(-3)