Last active
January 23, 2020 05:56
-
-
Save theoretick/3d35eb39595a11c2cec7 to your computer and use it in GitHub Desktop.
ruby #tap in elixir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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