Skip to content

Version 2017.5.1.1345-beta

Pre-release
Pre-release
Compare
Choose a tag to compare
@lassevk lassevk released this 01 May 12:03
· 164 commits to main since this release

This beta-release simply adds an extension method based on the diff operations that can be used to mutate lists.

A typical scenario is that you have a list that you want to mutate such that it has the same items as another collection. However, since something is observing changes to the list you want to mutate, you don't simply want to clear it and re-add all the elements it is supposed to have. Instead you would like to insert new elements in the right places and remove elements that should no longer be there.

The new extension method does just that:

It is called by:

(List<T> variable).MutateToBeLike(otherCollection, optionalComparer, optionalElementAligner);

In its simplest form:

(List<T> variable).MutateToBeLike(otherCollection);

It will take elements from otherCollection and insert into your list in the right places, and also remove items from your list if they should no longer be there.