@@ -276,8 +276,8 @@ Kotlin allows you to write even more concise code for functions by using lambda
276
276
For example, the following ` uppercaseString() ` function:
277
277
278
278
``` kotlin
279
- fun uppercaseString (string : String ): String {
280
- return string .uppercase()
279
+ fun uppercaseString (text : String ): String {
280
+ return text .uppercase()
281
281
}
282
282
fun main () {
283
283
println (uppercaseString(" hello" ))
@@ -290,7 +290,7 @@ Can also be written as a lambda expression:
290
290
291
291
``` kotlin
292
292
fun main () {
293
- println ({ string : String -> string .uppercase() }(" hello" ))
293
+ println ({ text : String -> text .uppercase() }(" hello" ))
294
294
// HELLO
295
295
}
296
296
```
@@ -304,10 +304,10 @@ Within the lambda expression, you write:
304
304
* the function body after the ` -> ` .
305
305
306
306
In the previous example:
307
- * ` string ` is a function parameter.
308
- * ` string ` has type ` String ` .
307
+ * ` text ` is a function parameter.
308
+ * ` text ` has type ` String ` .
309
309
* the function returns the result of the [ ` .uppercase() ` ] ( https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/uppercase.html )
310
- function called on ` string ` .
310
+ function called on ` text ` .
311
311
312
312
> If you declare a lambda without parameters, then there is no need to use ` -> ` . For example:
313
313
> ``` kotlin
@@ -328,7 +328,7 @@ To assign a lambda expression to a variable, use the assignment operator `=`:
328
328
329
329
```kotlin
330
330
fun main () {
331
- val upperCaseString = { string : String -> string .uppercase() }
331
+ val upperCaseString = { text : String -> text .uppercase() }
332
332
println (upperCaseString(" hello" ))
333
333
// HELLO
334
334
}
@@ -406,7 +406,7 @@ For example: `(String) -> String` or `(Int, Int) -> Int`.
406
406
This is what a lambda expression looks like if a function type for ` upperCaseString() ` is defined:
407
407
408
408
``` kotlin
409
- val upperCaseString: (String ) -> String = { string -> string .uppercase() }
409
+ val upperCaseString: (String ) -> String = { text -> text .uppercase() }
410
410
411
411
fun main () {
412
412
println (upperCaseString(" hello" ))
@@ -462,7 +462,7 @@ any parameters within the parentheses:
462
462
``` kotlin
463
463
fun main () {
464
464
// sampleStart
465
- println ({ string : String -> string .uppercase() }(" hello" ))
465
+ println ({ text : String -> text .uppercase() }(" hello" ))
466
466
// HELLO
467
467
// sampleEnd
468
468
}
0 commit comments