Just discovered that Kotlin `1.7-dev` has Context ...
# random
g
Just discovered that Kotlin
1.7-dev
has Context Receivers/Multiple Receivers Check this out ๐Ÿ˜ ๐Ÿ˜
๐Ÿ˜ 4
๐Ÿ‘Œ 5
m
I think we'll see it as soon as 1.6.20 as a preview feature (e.g. behind a compiler flag)
t
Nice! What theme are you using for your IDE?
a
I like really this feature, But the syntax kinda throws me off
๐Ÿ‘ 4
c
Awesome
g
I 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! ๐Ÿคž
@therealbluepandabear The theme is the Jetbrains port of "Plastic" =) https://plugins.jetbrains.com/plugin/18166-plastic https://plastictheme.com/
e
I like really this feature, But the syntax kinda throws me off
Same, especially the double indenting
with
m
Practically speaking, you probably wouldn't be using
with
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:
Copy code
fun doSomething(application: Application, route: Route) { /* ... */ }
could be condensed to:
Copy code
context(Application, Route)
fun doSomething() { /* ... */ }
And thus the caller would not need to explicitly pass either instance. At least, that is my understanding.
g
@Matthew Gast You were right about getting the preview!! ๐Ÿ˜ https://blog.jetbrains.com/kotlin/2022/02/kotlin-1-6-20-m1-released/
e
I hope so