Multi binding views


Hi all,
So basically I found code where You can make pure, clean and lazy view bind:

private fun <T : View> Activity.bind(@IdRes res: Int): Lazy<T> {
        return lazy { findViewById(res) as T }

usage is simple:
private val resultBox: EditText by bind(

So i came up with idea for multi bind ( using array of id’s) :

private fun <T : View> Activity.bind(@IdRes resources: Array<Int>): Array<Lazy<T>> {
    return { bind<T>(it) }.toTypedArray()

And usage ex:
private var buttons: Array<Lazy<Button>> = bind(arrayOf(,

This topic was previously a question, but it appeared to be very goofy type error. So I changed title for multi bind as it is the most relevant one if somebody will be searching for such a thing.