Skip to content

Instantly share code, notes, and snippets.

@theoretick
Last active January 23, 2020 05:56
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theoretick/3d35eb39595a11c2cec7 to your computer and use it in GitHub Desktop.
Save theoretick/3d35eb39595a11c2cec7 to your computer and use it in GitHub Desktop.
ruby #tap in elixir
iex(1)> defmodule Util do
...(1)> def tap(input, func) do
...(1)> func.(input)
...(1)> input
...(1)> end
...(1)> end
{:module, Util,
<<70, 79, 82, 49, 0, 0, 4, 212, 66, 69, 65, 77, 69, 120, 68, 99, 0, 0, 0, 164, 131, 104, 2, 100, 0, 14, 101, 108, 105, 120, 105, 114, 95, 100, 111, 99, 115, 95, 118, 49, 108, 0, 0, 0, 4, 104, 2, ...>>,
{:tap, 2}}
iex(2)> import Util
nil
iex(3)> require Logger
nil
iex(4)> "some very very long error message" |> tap(&Logger.debug/1) |> raise
** (RuntimeError) some very verylong error message
[debug] some very very long error message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment