3 ms·
Author here. When I started the project C#6 was just arriving. It's awesome to see the ValueTuples coming through for C#7. I have been adding some super-powe
by louthy 10y ago
Author here. When I started the project C#6 was just arriving. It's awesome to see the ValueTuples coming through for C#7. I have been adding some super-powers to them for lang-ext 2.0 (which is work in progress):
Example of extensions for ValueTuple<A,B,C> (there are extensions up to ValueTuple<A,B,C,D,E,F,G> and Tuple<A,B,C,D,E,F,G>)
https://github.com/louthy/language-ext/blob/type-classes/LanguageExt.Core/DataTypes/ValueTuple/Tuple3/ValueTuple3.Extensions.cs https://github.com/louthy/language-ext/blob/type-classes/Lan...
It allows cool stuff like this:
var abc = ('a', 'b').Add('c'); // ('a', 'b', 'c')
var abcd = ('a', 'b').Add('c').Add('d'); // ('a', 'b', 'c', 'd')
var abcd5 = ('a', 'b').Add('c').Add('d').Add(5); // ('a', 'b', 'c', 'd', 5)
var sumA = (1, 2, 3).Sum<TInt, int>(); // 6
var sumB = (2, 4, 8).Product<TInt, int>(); // 64
var flag = ("one", "two", "three").Contains<TString, string>("one"); // true
var str = ("Hello", " ", "World").Concat<TString, string>(); // "Hello World"
var list = (List(1, 2, 3), List(4, 5, 6)).Concat<TLst<int>, Lst<int>>(); // [1,2,3,4,5,6]