You can already do this today with IO.inspect(foo, label: "label") :)
Paul On Mon, Feb 19, 2018 at 7:32 PM pragdave <[email protected]> wrote: > When I use IO.inspect in a pipeline, I often find myself wanting to tag > the output with some kind of label: > > ~~~ elixir > get_name() > |> IO.inspect() > |> lookup_score() > |> IO.inspect > ~~~ > > so I sometimes write a trivial helper > > ~~~ > def dump(value, label) do > IO.puts "#{label}: #{inspect value}" > value > end > ~~~ > > This means I can write: > > ~~~ elixir > get_name() > |> dump("Name is") > |> lookup_score() > |> dump("score") > ~~~ > > Any chance we could > > 1. Add a `label: "text"` option to IO.inspect? > > 2. Add a new signature to IO.inspect, so that > > ~~~~ > def inspect(value, label) when is_binary(label) do > inspect(value, label: label) > end > ~~~ > > I'd happily do the PR > > > Dave > > > -- > You received this message because you are subscribed to the Google Groups > "elixir-lang-core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/elixir-lang-core/402e74bd-6c13-4433-b5f1-b6a42a2813d9%40googlegroups.com > <https://groups.google.com/d/msgid/elixir-lang-core/402e74bd-6c13-4433-b5f1-b6a42a2813d9%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAK%3D%2B-TsDrRn9vTuJTmPqcnCAscob3s0v4SfrEADDS%3D721nLJZA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
