menegatti
07/19/2017, 3:25 PMmenegatti
07/19/2017, 3:26 PMjackmiras
07/19/2017, 3:27 PMferoz_baig
07/19/2017, 3:27 PMferoz_baig
07/19/2017, 3:28 PMferoz_baig
07/19/2017, 3:33 PMwithoutclass
07/19/2017, 4:18 PMNumberFormatException
. However, I can evaluate the expression successfully while debugging as you can see from the watches window in the screenshot.roberto.guerra
07/19/2017, 4:20 PMwithoutclass
07/19/2017, 4:21 PMwithoutclass
07/19/2017, 4:23 PMnull
and an empty stack tracewithoutclass
07/19/2017, 4:24 PMjava.lang.NumberFormatException: null
withoutclass
07/19/2017, 4:29 PMInteger.parseInt()
as well as toInt()
seem to be sending null to Integer.java. At the call point in Kotlin I have a value, but inside Integer.java
the value is nullPaul Woitaschek
07/19/2017, 7:09 PMPaul Woitaschek
07/19/2017, 7:10 PMlucian
07/19/2017, 7:49 PMtipsy
07/19/2017, 7:50 PMreturn try {
true
} catch(..) {
false
}
vs
try {
return true
} catch(..) {
return false
}
tipsy
07/19/2017, 7:50 PMredrield
07/19/2017, 7:50 PMtipsy
07/19/2017, 7:50 PMredrield
07/19/2017, 7:51 PMtipsy
07/19/2017, 7:51 PMtipsy
07/19/2017, 7:52 PMjackmiras
07/19/2017, 7:54 PMtry{ } catch () { }
, otherwise I would stick with the second optionkevinmost
07/19/2017, 8:06 PMreturn
as high up in the expression as it can go personally, most of the time. I could see situations where having explicit return
in each branch would be more readable, especially if the try/catch is very longraulraja
07/19/2017, 8:06 PMreturn
at all.
fun doSomething(): Boolean =
try { true } catch (..) { false }
tipsy
07/19/2017, 8:08 PMtipsy
07/19/2017, 8:10 PMraulraja
07/19/2017, 8:12 PMraulraja
07/19/2017, 8:14 PMTry<A>
, Either<E, A>
and MonadError<F, E>
datatypes that abstract away try .. catch
blocks, error handling in general and represent Failure and Success as ADTs with folds and other useful combinators.