Skip to content

Instantly share code, notes, and snippets.

@louthy
Last active August 29, 2015 14:09
Show Gist options
  • Save louthy/f4cee2524d0d049b4378 to your computer and use it in GitHub Desktop.
Save louthy/f4cee2524d0d049b4378 to your computer and use it in GitHub Desktop.
public static class TupleExtensions
{
public static R Apply<T1, T2, R>(this Tuple<T1, T2> self, Func<T1, T2, R> func)
{
return func(self.Item1, self.Item2);
}
public static R Apply<T1, T2, T3, R>(this Tuple<T1, T2, T3> self, Func<T1, T2, T3, R> func)
{
return func(self.Item1, self.Item2, self.Item3);
}
public static R Apply<T1, T2, T3, T4, R>(this Tuple<T1, T2, T3, T4> self, Func<T1, T2, T3, T4, R> func)
{
return func(self.Item1, self.Item2, self.Item3, self.Item4);
}
public static R Apply<T1, T2, T3, T4, T5, R>(this Tuple<T1, T2, T3, T4, T5> self, Func<T1, T2, T3, T4, T5, R> func)
{
return func(self.Item1, self.Item2, self.Item3, self.Item4, self.Item5);
}
public static void Apply<T1, T2>(this Tuple<T1, T2> self, Action<T1, T2> func)
{
func(self.Item1, self.Item2);
}
public static void Apply<T1, T2, T3>(this Tuple<T1, T2, T3> self, Action<T1, T2, T3> func)
{
func(self.Item1, self.Item2, self.Item3);
}
public static void Apply<T1, T2, T3, T4>(this Tuple<T1, T2, T3, T4> self, Action<T1, T2, T3, T4> func)
{
func(self.Item1, self.Item2, self.Item3, self.Item4);
}
public static void Apply<T1, T2, T3, T4, T5>(this Tuple<T1, T2, T3, T4, T5> self, Action<T1, T2, T3, T4, T5> func)
{
func(self.Item1, self.Item2, self.Item3, self.Item4, self.Item5);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment