-
kotlin list 횡렬을 종렬로 변경카테고리 없음 2022. 11. 21. 11:42
data class A(val f: Int, val s: Int) fun <T> List<T>.prepend(element: T):List<T>{ val temp = this.toMutableList() temp.add(0,element) return temp.toList() } val az = listOf(A(1, 1), A(2, 1), A(3, 1)) val b = mutableListOf( az.map { it.f.toString() }.prepend("첫번째"), az.map { it.s.toString() }.prepend("두번째") ) b.forEach { it.forEach { print(it) } println() }