Mark Vogel
01/10/2023, 5:18 PMfun test() {
val bar = Bar()
val foo = Foo()
bar.doSomething() // How do you call this function
}
class Foo {
fun Bar.doSomething() {
// ...
}
}
class Bar {
// ...
}
mbonnin
01/10/2023, 5:20 PMfoo.apply {
bar.doSomething() // How do you call this function
}
Mark Vogel
01/10/2023, 5:21 PMmbonnin
01/10/2023, 5:21 PMmbonnin
01/10/2023, 5:22 PMmbonnin
01/10/2023, 5:23 PMmbonnin
01/10/2023, 5:24 PMMark Vogel
01/10/2023, 5:24 PMMaybe you'd be interested in context receivers tooI've read up a bit on them, but more couldn't hurt. Thanks!
Note it doesn't have anything to do with #kotlin-native
Maybe more #general-advice next timeAhh I didn't know which channel fit the best. I will be joining that one for sure
Mark Vogel
01/10/2023, 5:25 PMLandry Norris
01/10/2023, 5:48 PMfoo.apply
typically domes with the implication that you’re modifying foo. If you just need foo as a context, with(foo)
is more clear.Mark Vogel
01/10/2023, 9:21 PM