Skip to content

Commit 4131dfd

Browse files
committed
Added output for lambdas and changed to 4 spacing for tabs
1 parent 86a3d3c commit 4131dfd

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

_examples/lambdas.md

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,34 @@ Lambda functions ("lambdas") are a simple way to create functions ad-hoc. Lambda
99
```kotlin
1010
fun main(args: Array<String>) {
1111

12-
// All examples create a function object that performs upper-casing.
13-
// So it's a function from String to String
12+
// All examples create a function object that performs upper-casing.
13+
// So it's a function from String to String
1414

15-
val upperCase1: (String) -> String = { // 1
15+
val upperCase1: (String) -> String = { // 1
1616
str: String -> str.toUpperCase()
17-
}
17+
}
1818

19-
val upperCase2: (String) -> String = { str -> str.toUpperCase() } // 2
19+
val upperCase2: (String) -> String = { str -> str.toUpperCase() } // 2
2020

21-
val upperCase3 = { str: String -> str.toUpperCase() } // 3
21+
val upperCase3 = { str: String -> str.toUpperCase() } // 3
2222

23-
// val upperCase4 = { str -> str.toUpperCase() } // 4
23+
// val upperCase4 = { str -> str.toUpperCase() } // 4
2424

25-
val upperCase5: (String) -> String = { it.toUpperCase() } // 5
25+
val upperCase5: (String) -> String = { it.toUpperCase() } // 5
26+
27+
val upperCase6: (String) -> String = String::toUpperCase // 6
28+
29+
30+
println(upperCase2)
31+
println(upperCase1)
32+
println(upperCase3)
33+
println(upperCase5)
34+
println(upperCase6)
2635

27-
val upperCase6: (String) -> String = String::toUpperCase // 6
2836
}
37+
38+
39+
2940
```
3041
</div>
3142

0 commit comments

Comments
 (0)