brk
07/07/2017, 8:09 AMto<Type>OrNull()
string extensions https://github.com/Kotlin/KEEP/blob/master/proposals/stdlib/string-to-number.md
But don't you think it would a good idea to add generalized version of 'try-or-null' to stdlib? like:
val date = tryOrNull { myAwesomeDateTimeParser.parse("2017-13-32") }
which is equal to:
val date = try { myAwesomeDateTimeParser.parse("2017-13-32") } catch(e: Exception) { null }
voddan
07/07/2017, 8:21 AMvoddan
07/07/2017, 8:23 AMbrk
07/07/2017, 8:23 AMvoddan
07/07/2017, 8:23 AMtoIntOrNull()
doesn't catch an exceptionvoddan
07/07/2017, 8:24 AMvoddan
07/07/2017, 8:25 AMbrk
07/07/2017, 8:31 AMtry {x.toInt()} catch { null }
instead of current implementation of toIntOrNull()
which parses string by its own?voddan
07/07/2017, 9:44 AM