Skip to content

Commit

Permalink
Merge branch 'main' into renovate/major-all
Browse files Browse the repository at this point in the history
  • Loading branch information
nomisRev authored Feb 17, 2023
2 parents 29ac749 + 1d6a6aa commit d593bf0
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2069,10 +2069,10 @@ public inline fun <A, B> Either<A, B>.getOrHandle(default: (A) -> B): B =
*/
@Deprecated(
RedundantAPI + "Prefer if-else statement inside either DSL, or replace with explicit flatMap",
ReplaceWith("flatMap { b -> b.takeIf(predicate)?.right() ?: default().left() }")
ReplaceWith("flatMap { if (predicate(it)) Right(it) else Left(default(it)) }")
)
public inline fun <A, B> Either<A, B>.filterOrElse(predicate: (B) -> Boolean, default: () -> A): Either<A, B> =
ensure(default, predicate)
flatMap { if (predicate(it)) Right(it) else Left(default()) }

/**
* Returns [Right] with the existing value of [Right] if this is a [Right] and the given
Expand Down

0 comments on commit d593bf0

Please sign in to comment.