Simplify parseInt function (#3410)

Refactored the parseInt function to use toIntOrNull() for more concise and idiomatic error handling. This change simplifies the code and avoids the need for manual exception handling
This commit is contained in:
Tamim Hossain authored and GitHub committed 2024-08-03 10:33:28 +08:00
1 parent 146d20ce86
commit 52699967cd
1 file changed
+2 -7
@@ -63,15 +63,10 @@ object Utils {
}
fun parseInt(str: String?, default: Int): Int {
str ?: return default
return try {
Integer.parseInt(str)
} catch (e: Exception) {
e.printStackTrace()
default
}
return str?.toIntOrNull() ?: default
}
/**
* get text from clipboard
*/