Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How To Access The Failed Value From Either? #7

Closed
Ezirius opened this issue Aug 10, 2020 · 1 comment
Closed

How To Access The Failed Value From Either? #7

Ezirius opened this issue Aug 10, 2020 · 1 comment

Comments

@Ezirius
Copy link

Ezirius commented Aug 10, 2020

A good description of the issue can be found here:

In the example below, we have:

  • Type: Either<RangedNumberValueFailuresAbstract<int>, int>
  • If No Error: right(number)
  • If Error: left(RangedNumberValueFailuresAbstract.invalidNumber(failedNumberValue: number))

If we need to access the failedNumberValue in (failedNumberValue: number), how would we do it?

@Ezirius Ezirius changed the title How to extract the failed value from Either How To Access The Failed Value From Either? Aug 10, 2020
@Ezirius
Copy link
Author

Ezirius commented Aug 10, 2020

A good answer to the issue can be found here:

In the latter, the failedNumberValue is accessed as follows:

   final actual = testClass.getValue.fold(
     (l) => (l as RangedNumberValueFailuresAbstract).failedNumberValue,
     (r) => r,
   );

@Ezirius Ezirius closed this as completed Aug 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant