Hi All, i'm still learning Kotlin and i'm currentl...
# getting-started
a
Hi All, i'm still learning Kotlin and i'm currently learning how to use scope functions and would like to understand what the following mean for points 1 and 2
inline fun <T, R> T.let(*block*: (T) -> R): R
1) <T, R> T what does the extra T outside the <> mean
2) What does R mean
k
j
There are many concepts packed in the same function here, so it's normal to be a bit confused.
<T,R>
and the following
T
are 2 separate parts of the function definition. • The part between <> declares the type parameters of the function (because the function is generic). • The following
T
is the receiver of the function, because
let
is an _extension_ function. • The
R
is a generic type used as the return type of the function and also as the return type of the
block
argument (which is also a function)
😄 1
a
Thank you so much @Joffrey and @Kirill Grouchnikov 😄👍💯