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

Include a way to flip sides #4

Open
KyNorthstar opened this issue Oct 11, 2024 · 0 comments
Open

Include a way to flip sides #4

KyNorthstar opened this issue Oct 11, 2024 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@KyNorthstar
Copy link
Contributor

KyNorthstar commented Oct 11, 2024

There should be a way to flip which type is on which side.
For example, this would change an Either<String, Int> to an Either<Int, String>. Obviously, the value would switch sides too.

Something like this:

public extension Either {
    var flipped: Either<Right, Left> {
        switch self {
        case .left (let oldLeft ): return .right(oldLeft)
        case .right(let oldRight): return .left(oldRight)
        }
    }
}
@KyNorthstar KyNorthstar added enhancement New feature or request good first issue Good for newcomers labels Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant