Method I Wish Was There: PipeTo

Too much F# rots the brain…

Ok, maybe not, but too much F# really changes your C#. I find myself wanting to |> something that isn’t really linq-able (not IEnumerable).

After talking it over with my LINQ guru – Chris Marinos – for a good name for this operation, we both agreed that PipeTo is a good name.

public static void PipeTo<T>(this T source, Action<T> action)
{
  action(source);
}

Sure, its a dead simple implementation, but it means that I can do this:

blah.Where(…).Aggregate(…).PipeTo(Console.WriteLine)

2 thoughts on “Method I Wish Was There: PipeTo”

Comments are closed.