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

Suspending version of the fold operator? #102

Open
shubham08gupta opened this issue Nov 27, 2020 · 0 comments
Open

Suspending version of the fold operator? #102

shubham08gupta opened this issue Nov 27, 2020 · 0 comments

Comments

@shubham08gupta
Copy link

How about having a suspending version of the fold operator? Something like(please excuse the name):

suspend fun foldSuspend(fnL: suspend (L) -> Any, fnR: suspend (R) -> Any): Any =
        when (this) {
            is Left -> fnL(a)
            is Right -> fnR(b)
        }

Currently, it is:

 fun fold(fnL: (L) -> Any, fnR: (R) -> Any): Any =
        when (this) {
            is Left -> fnL(a)
            is Right -> fnR(b)
        }

Is it a good practice to keep 2 versions of the same function?

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