https://kotlinlang.org logo
#random
Title
r

rudolf.hladik

08/07/2020, 1:15 PM
is it possible to apply multiple contexts in extension function?
Copy code
interface Scope {
   fun SomeObject.foo(): Bar = Bar()
}

// interface Scope is not under my control and I need to add extension function on another object so it would behave the same way like it would be in interface

// like 
interface Scope {
   fun SomeObject.foo(): Bar = Bar()
   fun OtherObject.bar(): Foo = Foo()
}
e

elect

08/07/2020, 2:03 PM
no, use inheritance
m

Marc Knaup

08/07/2020, 7:24 PM
Exactly. Allowing more than one receiver for extensions is under active discussion: https://github.com/Kotlin/KEEP/pull/176
9 Views