dimsuz
05/24/2017, 6:35 PM{ fieldType -> errorText }
. Whenever user starts typing in some field (rxbinding is used) I do errors.minus(fieldType)
to clear a possible validation error, so in my case there will be a lot more cases when validation error does not exist rather than when it does (user started typing, paused, continued). but I agree that it may not be common.ilya.gorbunov
05/24/2017, 6:40 PMdimsuz
05/24/2017, 10:48 PMMap
interface which is a read-only one and behaves as though it's immutable on a consumer side.mg6maciej
05/24/2017, 10:51 PMsomeMutableMap - something
, which has to return new instance, because you could later modify someMutableMap
. And because there is no difference between Map
and MutableMap
at runtime, how would you know when it's safe to return same instance?dimsuz
05/24/2017, 10:55 PMMap.minus()
. I guess I didn't realize that there's no MutableMap.minus()
. Which can be introduced separately... but now I understood that I could get some HashMap
returned from java code and which one will be chosen then?... Right, so this can't be done I guess...mg6maciej
05/24/2017, 10:56 PMMap::betterMinus
🙂dimsuz
05/24/2017, 10:57 PMdimsuz
05/24/2017, 10:58 PMjw
05/27/2017, 3:35 AMjw
05/27/2017, 3:35 AMjw
05/27/2017, 3:58 PMmiha-x64
05/28/2017, 7:41 PMinfix fun Int.has(flag: Int) = this and flag == flag
infix fun Int.flagIf(condition: Boolean) = if (condition) this else 0
Haven't I reinvented a bicycle (or a wheel)? Or there's something similar in stdlib?
5 replies
++ for inline
, I want @InlineOnly
to be public for such tiny utils.mg6maciej
05/29/2017, 11:30 AMinline fun <K, V, R> Map<K, V>.map(transform: (K, V) -> R): List<R> {
return map { (k, v) -> transform(k, v) }
}
mg6maciej
05/29/2017, 11:33 AMmg6maciej
05/29/2017, 11:35 AMmyMap.map(::transformFunction)
instead of
myMap.map { (myKey, myValue) -> transformFunction(myKey, myValue) }
stepango
05/31/2017, 3:43 AMfun <P1, P2, R> Function2<P1, P2, R>.acceptPair(): (Pair<P1, P2>) -> R = { this(it.first, it.second) }
myMap.map(::transformFunction.acceptPair())
mg6maciej
05/31/2017, 4:33 AMacceptMapEntry
, but this is not the point. In my code I'm using the function I've put above (except made it internal) and it's much better than mapping transformFunction
to another function that accepts different parameters, cause I just need myMap.map(::transformFunction)
like normally when mapping `List`s. I'm just wondering if this is a good candidate for #stdlib, cause to me it feels like it is. There was an issue about it a while ago: https://youtrack.jetbrains.com/issue/KT-4167mg6maciej
06/02/2017, 2:50 PMIntrinsics.checkNotNull
. I was thinking about making a really small lib by grabbing necessary stuff from stdlib into a jar, so that when having a lib in Kotlin, it would require only this lib when used from Java.damian
06/02/2017, 2:57 PMkotlin-runtime
artifact. But I guess now it's assumed that anything in kotlin-stdlib
is fair gamejw
06/02/2017, 3:37 PMjw
06/02/2017, 3:37 PMjw
06/02/2017, 3:38 PMjw
06/02/2017, 3:49 PMvoddan
06/03/2017, 3:11 PMilya.gorbunov
06/03/2017, 3:12 PM+
?voddan
06/03/2017, 3:16 PMSequence.plus(Sequence)
voddan
06/03/2017, 3:22 PMIterable<T>(vararg subiterables: Iterable<T>): Iterable<T>
jw
06/03/2017, 4:45 PMilya.gorbunov
06/05/2017, 12:59 PMsequenceOf(iterable1, iterable2, iterable3, ...).flatten()
is close enoughvoddan
06/05/2017, 4:34 PM