public void EitherIterateLeftWhenLeft() { string expected = "Hello World"; string result = "World"; Either <string, int> either = "Hello "; EitherModule.IterateLeft( left => result = string.Concat(left, result) , either); Assert.AreEqual(expected, result); }
/// <summary>Applies the given function to <see cref="Either{TLeft, TRight}"/> value when <see cref="Either{TLeft, TRight}.IsLeft"/>.</summary> /// <typeparam name="TLeft">The type of the left value.</typeparam> /// <typeparam name="TRight">The type of the right value.</typeparam> /// <param name="action">The action to apply to left value of input <paramref name="either"/>.</param> /// <param name="either">the input either.</param> public static void IterateLeft <TLeft, TRight>(this Either <TLeft, TRight> either, Action <TLeft> action) => EitherModule.IterateLeft(action, either);