public void EitherIterateRightWhenRight() { int expected = 20; int result = 10; Either <string, int> either = 10; EitherModule.IterateRight( right => result += right , either); Assert.AreEqual(expected, result); }
/// <summary>Applies the given function to <see cref="Either{TLeft, TRight}"/> value when <see cref="Either{TLeft, TRight}.IsRight"/>.</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 right value of input <paramref name="either"/>.</param> /// <param name="either">the input either.</param> public static void IterateRight <TLeft, TRight>(this Either <TLeft, TRight> either, Action <TRight> action) => EitherModule.IterateRight(action, either);