Mahendran
10/03/2019, 11:31 AMgazpowell
10/03/2019, 12:37 PMMark Buikema
10/03/2019, 12:56 PMfilter()
, except it returns a list of the filtered items and a list of the unfiltered items? I need both listsDias
10/03/2019, 1:38 PMDias
10/03/2019, 1:39 PMLuis Munoz
10/03/2019, 3:25 PMtemp_man
10/03/2019, 6:44 PMCyril Scetbon
10/04/2019, 1:30 PMsnackycracky
10/04/2019, 2:10 PMEugen Martynov
10/04/2019, 4:19 PMEugen Martynov
10/04/2019, 4:19 PMgroostav
10/04/2019, 9:30 PMvalue: string
and a KPropoperty1<*, T>
, and I'm certain that the value
is a `toString()`'d version of T
and that T
is a common value type (eg String
, Double
, or enum class
). Is there a handy way for me to convert from my value
to an instance of the `KProperty`'s return type? I can write the switch but I sorta feel like somebody should've handled this for me.
I've got both guava and apache commons on my classpathtipsy
10/04/2019, 11:08 PMSlackbot
10/05/2019, 12:50 AMdewildte
10/05/2019, 2:14 PMmarcinmoskala
10/05/2019, 4:19 PMHexa
10/06/2019, 8:14 AMyawkat
10/06/2019, 10:08 AMLocalSubType
is missing the capture parameterdoodla
10/07/2019, 5:52 AMspand
10/07/2019, 6:29 AMoperator val invoke
property ? The error message seems to suggest its possible but I cant find a way
Modifier 'operator' is not applicable to 'member property without backing field or delegate'
class Foo {
companion object {
operator val invoke = {}
}
}
Sergio C.
10/07/2019, 10:59 AMjmfayard
10/07/2019, 11:03 AM$ sed -e 's/find/replace/' -e 's/find/replace/' filename
Colton Idle
10/07/2019, 11:11 AMpavel
10/07/2019, 5:47 PMfun pairTest(foo: Boolean, bar: Boolean) =
when (foo to bar) {
(true to true) -> 1
(true to false) -> 2
(false to true) -> 3
(false to false) -> 4
}
IntelliJ is saying that I need an else branch here. How come? And is there a better way to do this?kevin.cianfarini
10/07/2019, 6:17 PMtoken
here. internal enum class BencoderTokens(private val token: Byte) {
INTEGER('i'.toByte()),
STRING(':'.toByte()),
LIST('l'.toByte()),
DICT('d'.toByte()),
END('e'.toByte())
}
Sylvain Patenaude
10/07/2019, 7:46 PMbrain
10/07/2019, 8:45 PMPaul Woitaschek
10/08/2019, 7:08 AMOlekss
10/08/2019, 2:08 PMRobert
10/08/2019, 4:27 PMMap
? I tried extending HashMap
but it is final. When I extend Map
I have to implement all types of body functions like containsKey
, containsValue
, get
, isEmpty
and properties entries
, keys
, size
and values
Robert
10/08/2019, 4:27 PMMap
? I tried extending HashMap
but it is final. When I extend Map
I have to implement all types of body functions like containsKey
, containsValue
, get
, isEmpty
and properties entries
, keys
, size
and values
Alowaniak
10/08/2019, 4:42 PMdelegate
by?ilya.gorbunov
10/08/2019, 4:48 PMRobert
10/08/2019, 4:49 PMShawn
10/08/2019, 5:09 PMRobert
10/08/2019, 5:24 PMAbstractMap
, how do I set the initial values? As I can't use mapOf
to bootstrap it..Ruckus
10/08/2019, 5:33 PMrobertMapOf(vararg Pair<K, V>)
or Map<K, V>.toRobertMap()
Matteo Mirk
10/09/2019, 7:44 AMStephan Schroeder
10/09/2019, 12:21 PMRobert
10/09/2019, 6:57 PMcontains
etc. Instead I just extend the existing class with methods and add some new ones. I don't see how that is "wrong".apply
. I don't have and putAll
method or something, as it's a normal map
class RobertMap: AbstractMap<Int, String>() {
override val entries: Set<Map.Entry<Int, String>>
get() = throw UnsupportedOperationException()
}
public fun <Int, String> robertMapOf(vararg pairs: Pair<Int, String>): RobertMap = RobertMap(pairs.size).apply {}
mapOf
does this, which seems to create a LinkedHashMap by default? if (pairs.size > 0) pairs.toMap(LinkedHashMap(mapCapacity(pairs.size))) else emptyMap()
Ruckus
10/09/2019, 7:14 PMclass RobertMap(vararg entries: Pair<Int, String>) : AbstractMap<Int, String>() {
override val entries: Set<Map.Entry<Int, String>> =
Collections.unmodifiableSet(entries.mapTo(mutableSetOf()) { Entry(it.first, it.second) })
private class Entry(override val key: Int, override val value: String) : Map.Entry<Int, String>
}
which would let you use
val map = RobertMap(1 to "one", 2 to "two", ...)
Robert
10/09/2019, 7:18 PMColletions
but maybe that's because I'm in a MP project.
So I thought an unmodifiable Map would be cheaper than a mutable one. But from the code I guess this is not true; as it is change to mutableSet before it becomes the unmodifiable set?Ruckus
10/09/2019, 8:03 PMCollections.unmodifiableSet
is a Java stdlib function. I was optimizing for readability / LOC. You could save it more efficiently and use your own implementation of an abstract set to access it.Matteo Mirk
10/10/2019, 2:57 PMAbstractMap
, but it’s seldom the case. If instead you need a domain object that can be backed by a map, then I strongly advise to use composition and create your domain-specific interface, which of course won’t replicate any of the Map’s interface. If you need more explanation I can provide some code example, just ask.