arekolek
09/28/2017, 9:39 AM!! and catching NPE? You could then write a function similar to use (don’t mind the naming):
inline fun <T, R> T.suppressNpe(block: (T) -> R): R? = try {
block(this)
} catch (e: NullPointerException) {
null
}
fun foo(item: Item): Image? = item.suppressNpe {
Image(it.url!!, it.link!!, it.itemWidth!!.toInt(), it.itemHeight!!.toInt())
}