yole
01/05/2016, 6:25 PMmpcjanssen
01/05/2016, 6:25 PMyole
01/05/2016, 6:26 PMyole
01/05/2016, 6:26 PMmpcjanssen
01/05/2016, 6:27 PMmpcjanssen
01/05/2016, 6:37 PMnhaarman
01/05/2016, 7:34 PMIntArray.average()
allocate an iterator instead of using an index variable?
/**
* Returns an average value of elements in the array.
*/
public fun IntArray.average(): Double {
val iterator = iterator()
var sum: Double = 0.0
var count: Int = 0
while (iterator.hasNext()) {
sum += iterator.next()
count += 1
}
return if (count == 0) 0.0 else sum / count
}
yole
01/05/2016, 7:37 PMyole
01/05/2016, 7:38 PMnhaarman
01/05/2016, 7:54 PMmpcjanssen
01/05/2016, 8:01 PMnatpryce
01/05/2016, 8:01 PMnatpryce
01/05/2016, 8:02 PMnatpryce
01/05/2016, 8:02 PMnatpryce
01/05/2016, 8:04 PMsealed data class Article(val title: String) {
class RejectedArticle(title: String, val reason: String): Article(title)
class AcceptedArticle(title: String, val doi: DOI): Article(title)
}
apatrida
01/05/2016, 8:23 PMjw
01/05/2016, 9:20 PMcedric
01/05/2016, 9:58 PMBuild.kt
captures a timestamp of the build so it can display it in the app. This is cute but it defeats incremental compilation (since it changes all the time, the build rebuilds everything all the time), so I temporarily replaced that string with “” but u2020 then blows up because it tries to parse this as a date. So I restored the build timestamp for now.apatrida
01/05/2016, 9:58 PMcedric
01/05/2016, 9:58 PMasarazan
01/05/2016, 9:58 PMapatrida
01/05/2016, 9:58 PMsigmabeta
01/05/2016, 9:58 PMcedric
01/05/2016, 9:58 PMcedric
01/05/2016, 9:59 PMevanchooly
01/05/2016, 9:59 PMevanchooly
01/05/2016, 9:59 PMasarazan
01/05/2016, 10:09 PMevanchooly
01/05/2016, 10:10 PMasarazan
01/05/2016, 10:10 PM