mathiasbn
03/22/2017, 7:55 AMpublic static<T, R> Collector<T, R, R> of(Supplier<R> supplier,
BiConsumer<R, T> accumulator,
BinaryOperator<R> combiner,
Characteristics... characteristics)
The problem is, that the kotlin version (taking kotlin functions instead of SAMs) doesn't have vararg Characteristics, but instead Array<Characteristics>Andreas Sinz
03/22/2017, 8:29 AMmathiasbn
03/22/2017, 8:32 AM,emptyArray()
dmitry.petrov
03/22/2017, 8:35 AMmathiasbn
03/22/2017, 8:43 AMCollectors.of( {MySupplier()}, {r,t -> r.add(t)}, {r1,r2 -> r1.combine(r2)})
This does work:
Collectors.of( {MySupplier()}, {r,t -> r.add(t)}, {r1,r2 -> r1.combine(r2)}, emptyArray())
dmitry.petrov
03/22/2017, 8:44 AMmathiasbn
03/22/2017, 8:59 AMbeholder
03/22/2017, 9:04 AMval collector = Collector.of<String, StringBuilder>(
Supplier { StringBuilder() },
BiConsumer { b, s -> b.append(s) },
BinaryOperator { b1, b2 -> b1.append(b2) })
mathiasbn
03/22/2017, 9:09 AMbeholder
03/22/2017, 9:12 AMmathiasbn
03/22/2017, 9:15 AM,emptyArray()
to your callbeholder
03/22/2017, 9:20 AMdmitry.petrov
03/22/2017, 9:26 AMemptyArray()
parameter that doesn't add any type information fixes the lambdas case.
At least it deserves looking at.holgerbrandl
03/23/2017, 9:44 AMelements.filter { it is RAssignmentStatement }.map { it as RAssignmentStatement}
?vmironov
03/23/2017, 9:46 AMfilterIsInstance<RAssignmentStatement>()
dmitry.petrov
03/23/2017, 9:49 AMmapNotNull { it as? RAssignmentStatement }
, which is a bit more flexible in terms of fusing with other container traversing operationsholgerbrandl
03/23/2017, 9:56 AMmg6maciej
03/24/2017, 10:14 AMjava.util.Collections.shuffle
?mg6maciej
03/24/2017, 10:41 AMfun <T> List<T>.shuffled(r: Random): List<T> = ...
thokirillrakhman
03/24/2017, 12:02 PMmiha-x64
03/24/2017, 12:37 PMinline fun <T, reified R> Array<out T>.mapToArray(transform: (T) -> R): Array<R> =
Array<R>(size, { i -> transform(this[i]) })
benleggiero
03/24/2017, 2:42 PMteedee
03/24/2017, 3:49 PMmg6maciej
03/25/2017, 4:41 PMmg6maciej
03/28/2017, 11:48 AMval newList = list.removed(index)
?miha-x64
03/28/2017, 11:52 AMremoved(T)
, removedAt(Int)
?mg6maciej
03/28/2017, 11:52 AMremoved
already exists, it's called minus
and minusElement
.louiscad
03/28/2017, 11:59 AMval newList = list.minusIndex(i)
10 replies
Here you go: fun<E> List<E>.minusIndex(index: Int) = subList(0, index) + subList(index + 1, size)
mg6maciej
03/28/2017, 12:44 PMlist1.flatMap { e1 -> list2.flatMap { e2 -> list3.map { e3 -> /*work with e1, e2, e3*/ } }
?mg6maciej
03/30/2017, 10:06 AMfilterIndexedIsInstance
!