https://kotlinlang.org logo
#android
Title
# android
s

Saurabh

06/24/2020, 12:54 PM
Can I use interface implementation by delegates with an activity? I mean, normally, we pass the delegate object through constructor, but here, we don't construct the activity's object. Is delegation possible with objects not created at constructor invocation?
a

Adam Powell

06/24/2020, 2:04 PM
You can write a primary constructor that accepts the delegate object and a secondary no-args constructor that calls the primary constructor with the appropriate delegate parameter. (Or use default arguments and
@JvmOverloads
)