mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 01:08:50 -06:00
splitLongs: Handle NumberFormatException
This commit is contained in:
@@ -25,6 +25,12 @@ class StringUtils {
|
||||
|
||||
fun joinLongs(values: LongArray): String = values.joinToString(separator = ",")
|
||||
|
||||
fun splitLongs(str: String): LongArray = str.split(",").map { it.toLong() }.toLongArray()
|
||||
fun splitLongs(str: String): LongArray {
|
||||
return try {
|
||||
str.split(",").map { it.toLong() }.toLongArray()
|
||||
} catch (e: NumberFormatException) {
|
||||
LongArray(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user