althaf
08/08/2021, 5:39 PMfun make(rows: Int, cols: Int): String {
val table = StringBuilder()
for (rpos in 0..rows) {
table.append(START_ROW)
for (cpos in 0..cols) {
val cell = "${START_CELL}${cpos+rpos}${END_CELL}"
table.append(cell)
}
table.append(END_ROW)
}
return table.toString()
}
Dominaezzz
08/08/2021, 6:39 PMbuildString
can be usedephemient
08/08/2021, 7:20 PM.joinToString()
can be used as well (if using StringBuilder/buildString on the outside, then the variant .joinTo()
inside can avoid an extra intermediate string)althaf
08/11/2021, 5:26 AM