Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update 01_let.md #200

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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