use

inline fun <T : TypedArray?, R> T.use(block: (T) -> R): R