oday
02/20/2018, 3:37 PMpoohbar
02/20/2018, 3:40 PMpoohbar
02/20/2018, 3:41 PMmap
to all items:
items.map(..).first()
but this will apply map
to only the first item:
items.asSequence().map(..).first()
oday
02/20/2018, 3:42 PModay
02/20/2018, 3:42 PMpoohbar
02/20/2018, 3:42 PModay
02/20/2018, 3:43 PMpoohbar
02/20/2018, 3:43 PModay
02/20/2018, 3:43 PModay
02/20/2018, 3:44 PMpoohbar
02/20/2018, 3:45 PMpoohbar
02/20/2018, 3:46 PMmarstran
02/20/2018, 3:47 PMcollectionWithAMillionElements
.map { doSomethingExpensive(it) }
.forEach(::println)
If this is on a list, then it will do doSomethingExpensive
on every element before it starts printing.
If it's on a sequence, then it will call doSomethingExpensive
on the first element, print it, and the continue with the next element.oday
02/20/2018, 3:51 PModay
02/20/2018, 3:52 PMpoohbar
02/20/2018, 3:52 PModay
02/20/2018, 3:52 PMpoohbar
02/20/2018, 3:53 PModay
02/20/2018, 3:53 PMfirst()
oday
02/20/2018, 3:53 PMpoohbar
02/20/2018, 3:53 PModay
02/20/2018, 3:53 PModay
02/20/2018, 3:54 PModay
02/20/2018, 3:54 PModay
02/20/2018, 3:54 PMpoohbar
02/20/2018, 3:54 PModay
02/20/2018, 3:54 PMpoohbar
02/20/2018, 3:54 PMpoohbar
02/20/2018, 3:55 PModay
02/20/2018, 3:55 PMpoohbar
02/20/2018, 3:55 PM