You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, Succinc<T> can be used to split an IEnumerable<T> into a head and tail via the following method:
varconsResult= someEnumeration.ToConsEnumerable().Cons();// consResult contains Head and Tail
With C# 7 deconstruction though, a simple Deconstruct extension method on IEnumerable<T> would not only allow the above to be written as:
var(head, tail)= someEnumeration;
But also, a deconstruction can be recursive, so to extract the first three items from a list and have tail represent the fourth onwards elements, the code would simply be:
var(head1,(head2,(head3, tail)))= someList;
Modify Succinc<T> to support this.
The text was updated successfully, but these errors were encountered:
…g to get commit in before my train reached its destination! <blush/>)
DavidArno
changed the title
Make use of C# 7 deconstruct feature to "super charge" IEnmuerable cons support
Make use of C# 7 deconstruct feature to "super charge" IEnumerable<T> cons support
Jan 5, 2017
Marking this as a breaking change as I'm removing public static ConsResult<T> Cons<T>(this IEnumerable<T> collection) and replacing it with the deconstruct. ConsResult<T> Cons will still exist for IConsEnumerable though.
Currently, Succinc<T> can be used to split an
IEnumerable<T>
into a head and tail via the following method:With C# 7 deconstruction though, a simple
Deconstruct
extension method onIEnumerable<T>
would not only allow the above to be written as:But also, a deconstruction can be recursive, so to extract the first three items from a list and have
tail
represent the fourth onwards elements, the code would simply be:Modify Succinc<T> to support this.
The text was updated successfully, but these errors were encountered: