mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-12-18 06:40:07 +00:00
fixes
This commit is contained in:
parent
f226c2dfd6
commit
3b1124a804
@ -44,7 +44,7 @@ inline fun <T1, T2> Either.Companion.first(t1: T1): Either<T1, T2> = EitherFirst
|
|||||||
/**
|
/**
|
||||||
* @return New instance of [EitherSecond]
|
* @return New instance of [EitherSecond]
|
||||||
*/
|
*/
|
||||||
inline fun <T1, T2> Either.Companion.second(t1: T1): Either<T1, T2> = EitherFirst(t1)
|
inline fun <T1, T2> Either.Companion.second(t2: T2): Either<T1, T2> = EitherSecond(t2)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will call [block] in case when [Either.t1] of [this] is not null
|
* Will call [block] in case when [Either.t1] of [this] is not null
|
||||||
@ -63,3 +63,9 @@ inline fun <T1, T2, E : Either<T1, T2>> E.onSecond(crossinline block: (T2) -> Un
|
|||||||
t2 ?.let(block)
|
t2 ?.let(block)
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline fun <reified T1, reified T2> Any.either() = when (this) {
|
||||||
|
is T1 -> Either.first<T1, T2>(this)
|
||||||
|
is T2 -> Either.second<T1, T2>(this)
|
||||||
|
else -> error("Incorrect type of either argument $this")
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user