I have method that returns:
Either<Error, (int seconds, int count)> result = GetResult();
I need to return right value: (int NextDelayMs, int NextRetryCount)
But I can't figure out how to do it. I tried:
var toReturn = result.Map(x => x.Right);
but I get IEnumerable this way. What am I doing wrong?
You have to handle the left case as an
Eithervalue can be left typeLor right typeR.If you want to throw an exception when result is an
Erroryou can use this:But you should avoid this. It's better to stay within
EitherusingMap/Selectand pass any errors to the calling method:If you want to supply a fallback value in case of an error:
Basically
Eitheris similar toOptionregarding usage and you can find a good introduction here: https://github.com/louthy/language-ext/#option