commonMain.dev.inmo.micro_utils.matrix.RowBuilder.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of micro_utils.matrix Show documentation
Show all versions of micro_utils.matrix Show documentation
It is set of projects with micro tools for avoiding of routines coding
package dev.inmo.micro_utils.matrix
open class RowBuilder {
private val mutRow: MutableList = ArrayList()
val row: Row
get() = mutRow
fun add(t: T) = mutRow.add(t)
operator fun T.unaryPlus() = column(this)
fun column(t: T) = mutRow.add(t)
}
fun row(block: RowBuilder.() -> Unit): List = RowBuilder().also(block).row
fun RowBuilder.columns(elements: List) = elements.forEach(::column)
fun RowBuilder.columns(vararg elements: T) = elements.forEach(::column)