https://kotlinlang.org logo
Title
t

tipsy

10/26/2018, 2:07 PM
which of these would you prefer:
when (targetHandler) {
    is HandlerCollection -> targetHandler.apply { addHandler(defaultHandlers) }
    is HandlerWrapper -> targetHandler.apply { handler = defaultHandlers}
}
and
(targetHandler as? HandlerCollection)?.apply { addHandler(defaultHandlers) }
(targetHandler as? HandlerWrapper)?.apply { handler = defaultHandlers }
1️⃣ 19
s

Spike Baylor

10/26/2018, 3:14 PM
For my own knowledge, on the
when
block do you actually need to use apply in this case? or could you just call
targetHandler.addHandler(defaultHandlers)
and
targetHandler.handler = defaultHandlers
t

tipsy

10/26/2018, 3:28 PM
thanks, will fix that