Skip to content

Commit

Permalink
splitLongs: Handle NumberFormatException
Browse files Browse the repository at this point in the history
  • Loading branch information
iSoron committed Sep 9, 2022
1 parent 11f7260 commit 961fb76
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
}

0 comments on commit 961fb76

Please sign in to comment.