https://kotlinlang.org logo
#codereview
Title
# codereview
t

tipsy

10/26/2018, 2:07 PM
which of these would you prefer:
Copy code
when (targetHandler) {
    is HandlerCollection -> targetHandler.apply { addHandler(defaultHandlers) }
    is HandlerWrapper -> targetHandler.apply { handler = defaultHandlers}
}
and
Copy code
(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