Gavin Ray
02/07/2022, 1:29 AM1.7-dev
has Context Receivers/Multiple Receivers
Check this out ๐ ๐Matthew Gast
02/07/2022, 1:57 AMtherealbluepandabear
02/07/2022, 3:23 AMandylamax
02/07/2022, 4:30 AMCicero
02/07/2022, 9:32 AMGavin Ray
02/07/2022, 3:09 PMI think we'll see it as soon as 1.6.20 as a preview feature (e.g. behind a compiler flag)
That would be awesome, because I could put this to use immediately if IntelliJ had language support for it. It's a bummer you can't change IntelliJ Kotlin compiler version outside of distributed options. Fingers crossed! ๐ค
Gavin Ray
02/07/2022, 3:12 PMelect
02/08/2022, 10:42 AMI like really this feature, But the syntax kinda throws me offSame, especially the double indenting
with
Matthew Gast
02/08/2022, 2:37 PMwith
as it is mainly just there to set up the scope properly for testing. In a real world example, setting up a Ktor route would have you in multiple nested scopes in which you could set up a function for (e.g. being able to reference both Application
and Route
in the same extension function without needing to explicitly pass either instance).
For example, this:
fun doSomething(application: Application, route: Route) { /* ... */ }
could be condensed to:
context(Application, Route)
fun doSomething() { /* ... */ }
And thus the caller would not need to explicitly pass either instance. At least, that is my understanding.Gavin Ray
02/08/2022, 2:48 PMelect
02/08/2022, 2:53 PM