Animesh Sahu
11/12/2019, 4:10 PMSeri
11/12/2019, 4:14 PMapply()
has the inline
property, which allows it to copy the suspending context of its callerSeri
11/12/2019, 4:14 PMSeri
11/12/2019, 4:15 PMinline fun T.apply(block: T.() -> Unit): T
Animesh Sahu
11/12/2019, 4:16 PMkotlin
private suspend fun createUserSession(session: WebSocketServerSession, block: suspend UserSessionBuilder.() -> Unit): UserSession {
return UserSessionBuilder(session, server).apply(block).create()
}
here apply(block) give compiler error that type interference failedAnimesh Sahu
11/12/2019, 4:19 PMtseisel
11/12/2019, 4:20 PMapply
, but should instead write :
return UserSessionBuilder(session, server).apply { block() }.create()
Animesh Sahu
11/12/2019, 4:21 PMSeri
11/12/2019, 4:23 PM