Skip to content

Consider adding the possibility to unwrap a result with a switch statement #20

@Lucartas

Description

@Lucartas

Hello,

the idea is to be able to write something like this:

Result<String> getSomethingPretty() {
  if(isOk) {
    return 'OK!'.toSuccess();
  } else {
     return Exception('Not Ok!').toFailure();
  }
}

void main() {
  final result = getSomethingPretty();
  switch(result) {
      case Success():
          print("${result.success}");
          break;
      case Error():
        print("${result.error}");
        break;
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions