```//Trying to be functional (0 until tabCount) ...
# codereview
d
Copy code
//Trying to be functional
(0 until tabCount)
    .map { getTabAt(it)?.apply { customView = getTabItem(this@tabLayout) } }
    .zip(tabImages) { tab, drawableId -> tab?.setIcon(drawableId) }
    .apply { first()?.customView?.isSelected = true }

//Kotlin style
for (i in 0 until tabCount) {
    val tab = getTabAt(i)
    tab?.apply {
        customView = getTabItem(this@tabLayout)
        customView?.isSelected = i == 0
        setIcon(tabImages[i])
    }
}
Can't judge between the two, but somehow the functional one looks too verbose. Is it possible to improve it?