From 9dc2edfa3711a123f97980606810aeba1f5da987 Mon Sep 17 00:00:00 2001 From: taku333 Date: Sat, 25 May 2024 12:16:37 +0900 Subject: [PATCH] Update 02_run.md --- examples/06_scope_functions/02_run.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/06_scope_functions/02_run.md b/examples/06_scope_functions/02_run.md index 068eb73..9e959e6 100644 --- a/examples/06_scope_functions/02_run.md +++ b/examples/06_scope_functions/02_run.md @@ -7,9 +7,9 @@ The difference is that inside `run` the object is accessed by `this`. This is us fun main() { //sampleStart - fun getNullableLength(ns: String?) { + fun getNullableLength(ns: String?): Int? { println("for \"$ns\":") - ns?.run { // 1 + return ns?.run { // 1 println("\tis empty? " + isEmpty()) // 2 println("\tlength = $length") length // 3 @@ -17,7 +17,9 @@ fun main() { } getNullableLength(null) getNullableLength("") - getNullableLength("some string with Kotlin") + val length = getNullableLength("some string with Kotlin") + println("// 3 length: $length") + //sampleEnd } ```