what is the best way in the stdlib (without Java) ...
# stdlib
d
what is the best way in the stdlib (without Java) to convert a number to a string with thousands separated by commas? e.g. “2029292” which becomes “2,029,292"
d
This is what I could come up with:
Copy code
number.toString().toList().asReversed()
    .chunked(3)
    .map { it.asReversed().joinToString(separator = "") }
    .asReversed()
    .joinToString(separator = ",")
Can probably be optimized.
d
thanks!