Paul Dhaliwal
08/07/2019, 8:13 PMContextCompat.getColor(context, color.colorPrimaryDark)
which gives the error “type mismatch Required Context, Found Context?” I can get around this error by using “context as Context” or “context!!“, however these don’t feel like the right approaches. The Kotlin doc says !! is for “NPE-lovers” which I am not lol. What’s the best way to handle these situations? I’m still new to Kotlin and development in general and don’t want to develop any bad habits. Thanks!jw
08/07/2019, 8:14 PMcontext!!
is fine. there's probably also requireContext()
wherever you're calling this fromPaul Dhaliwal
08/07/2019, 8:40 PMAslam Hossin
08/08/2019, 2:10 AMjw
08/08/2019, 2:18 AMnull
in that case. But that seems exceedingly unlikely and even in the case where it is likely you probably want to fix your design so that the code bails much earlier.ahulyk
08/09/2019, 12:44 PMrequireContext()
is better than context!!
from my point of view