jelloranger
08/21/2017, 8:52 AMarekolek
08/21/2017, 10:25 AMforEach(1, 2, 3) { print(it) }
lovis
08/21/2017, 10:35 AM(1..3).forEach { print(it) }
? (with ranges)
or listOf(1,2,3).forEach { print(it) }
(with a new list)lovis
08/21/2017, 10:38 AMarekolek
08/21/2017, 10:44 AM1,2,3
was misleading. One use case is to be able to apply an action to a couple of views specified inline, like forEach(title, description, email) { it.text = "" }
. I know I could write listOf
, but wanted to avoid it if I can 😛arekolek
08/21/2017, 10:47 AMtakeIf
would do smart-castinghorse_badorties
08/21/2017, 11:27 AMinline fun forEach(vararg elements: Any, action: (Any) -> Unit) {
elements.forEach(action)
}
data class Foo(val name: String)
fun main(args: Array<String>) {
forEach("333", true, 1, Foo("foo")) { println(it) }
}
horse_badorties
08/21/2017, 11:28 AMit.text = ""
would not be possible of causehorse_badorties
08/21/2017, 11:32 AMkarelpeeters
08/21/2017, 11:33 AMmichaelzinn
08/21/2017, 11:49 AMmichaelzinn
08/21/2017, 11:50 AMPaul Woitaschek
08/21/2017, 11:54 AMPaul Woitaschek
08/21/2017, 11:26 PMsorted().reversed()
i do toSequence().sorted().reversed().toList()
Paul Woitaschek
08/21/2017, 11:27 PMkarelpeeters
08/21/2017, 11:42 PMkarelpeeters
08/21/2017, 11:44 PMsortedWith(Comparator.reverseOrder())
@Paul Woitaschekfitzoh
08/22/2017, 12:01 AMsortedDescending()
melston
08/22/2017, 12:18 AMkarelpeeters
08/22/2017, 12:19 AMkarelpeeters
08/23/2017, 2:43 PMkarelpeeters
08/23/2017, 2:43 PM(0 .. size).toSet()
should work.Danilo Herrera
08/23/2017, 2:44 PMkarelpeeters
08/23/2017, 2:46 PM.toMutableSet()
, I'm not sure.Danilo Herrera
08/23/2017, 2:50 PMmichaelzinn
08/23/2017, 3:29 PMval notNull = getBla() ?: { log("error"); return }()
?karelpeeters
08/23/2017, 3:30 PM?: run {...}
michaelzinn
08/23/2017, 3:33 PMgroostav
08/23/2017, 5:13 PMevent
and to some degree delegate
?groostav
08/23/2017, 5:13 PM