Sam Stone
11/03/2022, 10:20 PMdata class Foo(a: String, b: String)
val foo: Foo = listOf("one", "two").mapToClass<Foo>()
There wouldn’t necessarily be type-safety, but it would be a cool language feature. It comes up often when parsing CSVs. I end up doing
Files.readAllLines(path).map {
it.split(",").let {
Foo(
it[0],
it[1]
...
)
}
}
Instead of being able to do Files.readAllLines(path).toCSV<Foo>()
or Files.readAllLines(path).map { it.split(",").mapToClass<Foo>() }
ephemient
11/03/2022, 10:26 PMSam Stone
11/03/2022, 10:47 PMSam Stone
11/03/2022, 10:48 PM