FluentResults icon indicating copy to clipboard operation
FluentResults copied to clipboard

182 Add enumerable support for Merge

Open Kysluss opened this issue 6 months ago • 0 comments

Adds a MergeFlat method that will take in collections of TValue in your result set and return them as a single flattened IEnumerable<TValue>

Unfortunately, due to how C# infers type parameters for encapsulating types, you will need to specify the TValue and TArray types where TArray : IEnumerable<TValue>

var result1 = Result.Ok(new string[] { "A", "B" });
var result2 = Result.Ok(new string[] { "C", "D" });
var result3 = Result.Ok(new string[] { "E", "F" });

// Will contain ["A", "B", "C", "D", "E", "F"]
var mergedResult = Result.MergeFlat<string, string[]>(result1, result2, result3);

Closes #182

Kysluss avatar Jul 31 '24 23:07 Kysluss