LastExceed
03/28/2022, 10:34 AMrepeat(10) {
foo()
delay(500) //problem: causes trailing delay
}
i could of course do this:
foo()
repeat(10) {
delay(500)
foo()
}
but it looks kinda ugly to mephldavies
03/28/2022, 10:37 AMrepeat(10) {
if (it > 0) delay(500)
foo()
}
should do the trickLastExceed
03/28/2022, 10:40 AMMichael de Kaste
03/28/2022, 12:58 PMLastExceed
03/28/2022, 3:03 PMinline
functions whereever possible for performance gains. even intellij tells you to stop because of how insignificant the difference isKlitos Kyriacou
03/28/2022, 4:49 PMArray(10) { foo() }.joinToString(delay(500).let {""})
LastExceed
03/28/2022, 4:55 PMjoinToString
is called afterwardsephemient
03/28/2022, 5:50 PMflow { repeat(10) { emit(foo()) } }
.fold(false) { doDelay, _ ->
if (doDelay) delay(100)
true
}
(the slightly-more natural
sequence { repeat(10) { yield(foo()) } }
.zipWithNext { _, _ -> delay(100) }
.toList()
doesn't work with suspend functions)LastExceed
03/28/2022, 5:55 PMMichael de Kaste
03/29/2022, 8:31 AM