Use filterIsInstance in getAll methods
This commit is contained in:
parent
7be628e79e
commit
1933c9f845
@ -1,5 +1,5 @@
|
|||||||
group=com.github.michaelbull.kotlin-result
|
group=com.github.michaelbull.kotlin-result
|
||||||
version=1.0.1-SNAPSHOT
|
version=1.1.1-SNAPSHOT
|
||||||
|
|
||||||
dokkaVersion=0.9.15
|
dokkaVersion=0.9.15
|
||||||
gradleReleaseVersion=2.6.0
|
gradleReleaseVersion=2.6.0
|
||||||
|
@ -103,7 +103,7 @@ fun <V, E> getAll(vararg results: Result<V, E>) = results.asIterable().getAll()
|
|||||||
* @return The extracted [Ok] elements.
|
* @return The extracted [Ok] elements.
|
||||||
*/
|
*/
|
||||||
fun <V, E> Iterable<Result<V, E>>.getAll(): List<V> {
|
fun <V, E> Iterable<Result<V, E>>.getAll(): List<V> {
|
||||||
return filter { it is Ok }.map { (it as Ok).value }
|
return filterIsInstance<Ok<V>>().map { it.value }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -126,7 +126,7 @@ fun <V, E> getAllErrors(vararg results: Result<V, E>) = results.asIterable().get
|
|||||||
* @return The extracted [Error] elements.
|
* @return The extracted [Error] elements.
|
||||||
*/
|
*/
|
||||||
fun <V, E> Iterable<Result<V, E>>.getAllErrors(): List<E> {
|
fun <V, E> Iterable<Result<V, E>>.getAllErrors(): List<E> {
|
||||||
return filter { it is Error }.map { (it as Error).error }
|
return filterIsInstance<Error<E>>().map { it.error }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user