Skip to content

Commit 2473eec

Browse files
author
Ivan Volkov
committed
Added KDocs for filterWhen
1 parent ecefd52 commit 2473eec

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

utbot-core/src/main/kotlin/org/utbot/common/FilterWhen.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
package org.utbot.common
22

3-
// TODO: add docs
3+
/**
4+
* If [condition] is true, returns list containing only elements, matching [predicate].
5+
* Otherwise, returns list with all elements of collection
6+
*/
47
inline fun <T> Iterable<T>.filterWhen(condition: Boolean, predicate: (T) -> Boolean): List<T> =
58
if (condition)
69
this.filter(predicate)
710
else
811
this.toList()
912

10-
// TODO: add docs
13+
/**
14+
* If [condition] is true, returns sequence containing only elements, matching [predicate].
15+
* Otherwise, leaves sequence unchanged
16+
*/
1117
fun <T> Sequence<T>.filterWhen(condition: Boolean, predicate: (T) -> Boolean): Sequence<T> =
1218
if (condition)
1319
this.filter(predicate)

0 commit comments

Comments
 (0)