Skip to content

Commit 321c0c0

Browse files
kotlin-tour-functions.md : fix filter predicate explanation (#4925)
* kotlin-tour-functions.md : fix filter predicate explanation The predicate doesn't do the filtering, .filter() does * Apply suggestions from code review Co-authored-by: Sarah Haggarty <[email protected]> --------- Co-authored-by: Sarah Haggarty <[email protected]>
1 parent f545cc0 commit 321c0c0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

docs/topics/tour/kotlin-tour-functions.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,10 +396,10 @@ fun main() {
396396
```
397397
{kotlin-runnable="true" kotlin-min-compiler-version="1.3" id="kotlin-tour-lambda-filter"}
398398
399-
The `.filter()` function accepts a lambda expression as a predicate:
399+
The `.filter()` function accepts a lambda expression as a predicate and applies it to each element of the list. The function keeps an element only if the predicate returns `true`:
400400
401-
* `{ x -> x > 0 }` takes each element of the list and returns only those that are positive.
402-
* `{ x -> x < 0 }` takes each element of the list and returns only those that are negative.
401+
* `{ x -> x > 0 }` returns `true` if the element is positive.
402+
* `{ x -> x < 0 }` returns `true` if the element is negative.
403403
404404
This example demonstrates two ways of passing a lambda expression to a function:
405405

0 commit comments

Comments
 (0)