https://kotlinlang.org logo
#announcements
Title
# announcements
n

nkiesel

10/14/2019, 11:01 PM
Is there a way to force the compiler to call an object method before this object is passed as a parameter to another method or returned to the caller? The concrete use case is a Builder for which
applyBindings()
(a normal method of that builder) must be called before it's passed on. We currently do that manually, but this of course leads to bugs where this call was forgotten.
x

Xavier F. Gouchet

10/15/2019, 7:18 AM
This is typically the kind of use case for an Aspect weaving. There are some tools that allow you to inject code automatically at certain points. In theory it is possible in Kotlin (Spring uses that).
n

nkiesel

10/15/2019, 8:22 AM
interesting idea. I will see if that can work for me
2 Views