s.luhmirins
02/23/2017, 10:11 AMdarkmoon_uk
02/23/2017, 10:15 AMAndreas Sinz
02/23/2017, 10:42 AMclass CounterMap(val map: MutableMap<String, Int>): MutableMap<String, Int> by map {
override fun put(key: String, value: Int): Int? {
val previousValue = map[key]
map[key] = (previousValue ?: 0 ) + value
return previousValue
}
}
elezium
02/26/2017, 2:57 AMliminal
02/26/2017, 7:08 PMmiha-x64
02/27/2017, 2:06 PMMap<String, exactly Any>
, not out Any
, to use with Retrofit? Currently using MutableMap
as a workaround.quver
02/27/2017, 4:31 PMcedric
02/27/2017, 6:44 PMokkero
02/28/2017, 11:53 AMMap<String, Class<?>> hm = new HashMap<>();
(notice the wildcard)north
02/28/2017, 12:16 PMprivate val myMap = mutableMapOf<String, Long>()
private fun defaultValue(): Long = 5
fun get(key: String) {
myMap.getOrPut(key, ::defaultValue)
}
jan.rabe
03/02/2017, 3:59 PMrobin
03/03/2017, 2:50 PMfun main(args: Array<String>)
anywhere in your project?xxxifan
03/03/2017, 2:54 PMgbm
03/04/2017, 2:14 PMxxxifan
03/05/2017, 2:09 PMbenleggiero
03/05/2017, 3:55 PMdata class
be extended?camdenorrb
03/06/2017, 5:33 AMangarron
03/06/2017, 9:44 PMdata class
. It's easiest to understand by example. I have something like this contrived example:
data class ManageUserHelper(val canKick: Boolean, val canBan: Boolean)
but I want to have an initialization flow where those booleans are computed:
constructor(val actingUser: User, val targetUser: User, val relationship: Relationship) {
val canKick = // do something complicated w/ users + relationship
val canBan = // do something complicated w/ users + relationship, which may depend on the above
this(canKick, canBan)
}
^ Obviously the above does not compile because the secondary constructor does not immediately delegate to the primary constructor. Until now I have solved this problem by moving that secondary constructor into a buildFrom
method inside of a companion object
but that feels messy to me. Is there a more idiomatic way to accomplish what I want?
Thanks for the help, and again let me know if there is a better place to ask!angarron
03/06/2017, 10:19 PMehubbard
03/06/2017, 11:45 PMminikloon
03/07/2017, 7:32 AMbenleggiero
03/10/2017, 1:41 AMinline
sacrifices the size of the binary in favor of fewer stack frames and faster execution. Is that correct? Is it more subtle or complex? Is there anything else it does that I should know?nkiesel
03/10/2017, 2:14 AMalso
instead of apply
?deusex
03/11/2017, 8:59 PMelezium
03/14/2017, 1:27 AMkingsley
03/14/2017, 1:43 PMsource.retryWhen { errors ->
errors
.zipWith(Observable.range(1, 3)) { n, i -> i }
.flatMap { retryCount -> Observable.timer(Math.pow(5.0, retryCount.toDouble()).toLong(), TimeUnit.SECONDS) }
}
I suppose you're on RxJava1?appasni
03/17/2017, 6:06 PMString
and not String?
or letting it be inferred which would probably be String?
voddan
03/17/2017, 6:26 PMval s = buildSequence { while(true) yieldAll(list) }
menegatti
03/18/2017, 12:17 PM(Boolean) -> String
is the function typeminikloon
03/19/2017, 9:42 AMminikloon
03/19/2017, 9:42 AMvoddan
03/19/2017, 9:51 AMminikloon
03/20/2017, 2:03 AMhttp://i.imgur.com/chGCZUS.png▾
voddan
03/20/2017, 3:33 AMminikloon
03/20/2017, 1:49 PM