Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/06_scope_functions/01_let.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ The Kotlin standard library function `let` can be used for scoping and null-chec
The object is accessible inside the block by the reference `it` (by default) or a custom name.

```run-kotlin
//sampleStart
fun customPrint(s: String) {
print(s.uppercase())
}

fun main() {
//sampleStart

val empty = "test".let { // 1
customPrint(it) // 2
it.isEmpty() // 3
Expand Down Expand Up @@ -39,9 +40,8 @@ fun main() {
printNonNull(null)
printNonNull("my string")
printIfBothNonNull("First","Second")
//sampleEnd
}

//sampleEnd
```

1. Calls the given block on the result on the string "_test_".
Expand Down