Kernel.tap
You're seeing just the macro
tap
, go back to Kernel module for more information.
Pipes value
to the given fun
and returns the value
itself.
Useful for running synchronous side effects in a pipeline.
Examples
iex> tap(1, fn x -> x + 1 end)
1
Most commonly, this is used in pipelines. For example, let's suppose you want to inspect part of a data structure. You could write:
%{a: 1}
|> Map.update!(:a, & &1 + 2)
|> tap(&IO.inspect(&1.a))
|> Map.update!(:a, & &1 * 2)