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)
What about this:
public static T With(this T e, Action h) where T : class
{
h(e);
return e;
}
Comment system ate the generics 🙂