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

leosan

08/24/2018, 10:50 AM
Copy code
private val imageResource: Int? by lazy { arguments?.getInt(ARG) }
//Doesn't work compiler complain it is not integer
imageResource?.let { ivIcon.setImageResource(it) }
//Works
imageResource?.run { ivIcon.setImageResource(this) }
is there a way to use the `@DrawableRes`with delegates? or do I have to lose the perk of using
setImageResource
? Edit: It works with
run
what am I missing here?
d

Denis A

08/24/2018, 11:16 AM
I use typical ivIcon.setImageResource(arguments?.getInt(arg) ?: R.drawable.default_icon)
but let and val constructions is correct
l

leosan

08/24/2018, 11:18 AM
Could do that too, but now I’m wondering why the compiler complain
it
is not integer but it works with
run
it was actually some android studio error, now its working