Skip to content

Commit d16c8be

Browse files
committed
doc update
1 parent 691b245 commit d16c8be

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* reference
66
* https://kotlinlang.org/docs/reference/scope-functions.html
77
* https://www.manning.com/books/kotlin-in-action
8+
* https://stackoverflow.com/questions/33190613/what-does-a-kotlin-function-signature-with-t-mean
89
* please refer previously: https://github.com/mtumilowicz/groovy258-dsl-closure-workshop
910
* this workshop is analogous but in kotlin
1011

@@ -49,7 +50,7 @@
4950
5051
## lambdas with receivers
5152
* the ability to call methods of a different object in the body of a lambda
52-
* example (from standard library)
53+
* example (from standard library - look for others)
5354
* `apply` - calls the specified function `block` with `this` value as its receiver and returns
5455
`this` value
5556
```
@@ -58,7 +59,7 @@
5859
contract {
5960
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
6061
}
61-
block()
62+
block() // this.block()
6263
return this
6364
}
6465
```
@@ -72,10 +73,6 @@
7273
}
7374
println(name) // Michal
7475
```
75-
* `T.run(block: T.() -> R)`
76-
* calls the specified function `block` with `this` value as its receiver and returns its result
77-
* `with(receiver: T, block: T.() -> R)`
78-
* calls the specified function `block` with `receiver` as its receiver and returns its result
7976
* lambdas with receiver and extension functions
8077
* note that an extension function is, in a sense, a function with a receiver
8178
* `this` refers to the instance of the type the function is extending
@@ -105,6 +102,10 @@
105102
```
106103
sign("Approved by: ", "Michal Tumilowicz")
107104
```
105+
* what is exactly `T.()`?
106+
* `fun doSomethingWithInt(receiver: Int.() -> Unit)`
107+
* how this is different from Regular lambda like `() -> Unit`?
108+
* similar to extension function we could call: `5.receiver()`
108109
* therefore, a lambda with a receiver looks exactly the same as a regular lambda in the source code
109110
110111
## infix

0 commit comments

Comments
 (0)