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)
Denis A
08/24/2018, 11:18 AM
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
leosan
08/24/2018, 11:47 AM
it was actually some android studio error, now its working