voddan
12/01/2015, 7:39 PMvoddan
12/02/2015, 6:47 AMassertFailsWith<T>(class: KClass<T> = T)
syntax. For this to be convenient Kotlin will have to change its rules for default parameters. By the java convention class
parameter should go first. But in kotlin all parameters after a default one must be named. So the usage would be assertFailsWith<MyClass>(message="one word too long")
.voddan
12/02/2015, 6:48 AMgabrielborges
12/02/2015, 11:30 PMfilterIndexed
, forEachIndexed
and mapIndexed
, as well as a few variants of each of those. However, there's no indexed counterpart of reduce
. Could anyone shed some light on the reason?voddan
12/03/2015, 7:47 AMvoddan
12/03/2015, 7:54 AMString.toInt(): Int?
voddan
12/03/2015, 7:55 AMvoddan
12/03/2015, 7:56 AMgabrielborges
12/03/2015, 10:12 AMvoddan
12/03/2015, 10:24 AMtoInt
or toIntOrNull
?gabrielborges
12/03/2015, 10:25 AMvoddan
12/03/2015, 10:29 AMorangy
voddan
12/03/2015, 10:31 AMorangy
!!
way too often, and do not even see the number that it couldn’t parse. On the other hand, when handling user input, it could be nice to have nullable variant, so that you can fail gracefully, with some default, or better exception, or something. Too bad actual NumberFormatException doesn’t give us the reason of failure, so it’s not suitable for user feedback.orangy
toInt
, now what?” If you find it more often would be s.toInt() ?: throw SomeException()
it wouldn’t be much better than throw it right away.voddan
12/03/2015, 10:42 AMorangy
voddan
12/03/2015, 10:44 AMvoddan
12/03/2015, 10:44 AMvoddan
12/03/2015, 10:46 AMvoddan
12/03/2015, 10:46 AMvoddan
12/03/2015, 10:48 AMvoddan
12/03/2015, 10:49 AMvoddan
12/03/2015, 12:09 PMnatpryce
12/03/2015, 12:11 PMorangy
natpryce
12/03/2015, 2:09 PMorangy
natpryce
12/03/2015, 2:10 PM