LoginSignup
4

More than 5 years have passed since last update.

C# で Ruby の tap

Posted at
ObjectExtensions.cs
public static class ObjectExtensions {
  public static T Tap<T>(this T t, System.Action<T> f) {
    f(t);
    return t;
  }
}

これでタップし放題ですね

var multiplied = numbers.Select((e) => e * 10).Tap((list) => Debug.Log(list));

参考: Ruby の Object#tap

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4