mg6maciej
01/20/2017, 8:19 PMreduce
.mg6maciej
01/20/2017, 8:20 PMflatMap
. Reduce might be better for you.robin
01/20/2017, 8:24 PMval moments: List<ListItem> = moments
.groupBy { it.timePosted!!.toLocalDate().withDayOfMonth(1) }
.map { it.key to it.value.map { ListItem.MomentItem(it) } }
.flatMap { listOf(ListItem.HeaderItem(it.first)) + it.second }
Now to clean this up quite a bit, lots of stuff in there I still don't like 😄mg6maciej
01/20/2017, 8:26 PMrobin
01/20/2017, 8:47 PMvoddan
01/21/2017, 5:23 AMfor
loop would be much better in this regardnimtiazm
01/21/2017, 5:54 AMcedric
01/21/2017, 5:55 AMnimtiazm
01/21/2017, 5:57 AMilya.gorbunov
01/21/2017, 6:00 AMfor
?voddan
01/21/2017, 6:01 AMrobin
01/23/2017, 8:31 AMpcarrier
01/24/2017, 5:05 AMpcarrier
01/24/2017, 5:06 AMlistOf(1,2,3,4,5).toSequence().batch(2).forEach{println(it)} => 1,2 ; 3,4 ; 5
orangy
orangy
voddan
01/24/2017, 5:54 AMilya.gorbunov
01/24/2017, 6:34 AMvoddan
01/24/2017, 6:46 AMroman.belov
01/24/2017, 8:23 PMevanchooly
01/24/2017, 8:24 PMevanchooly
01/24/2017, 8:24 PMfellshard
01/24/2017, 8:25 PMdalexander
01/24/2017, 8:28 PMminOf
and maxOf
to avoid potential collisions with variables named min
and max
in existing code?fellshard
01/24/2017, 8:29 PMfellshard
01/24/2017, 8:29 PMfellshard
01/24/2017, 8:30 PMdalexander
01/24/2017, 8:31 PMteedee
01/24/2017, 8:38 PMFiles
class as extension methods on the Path
class for the jre7 stdlib?