rrader
12/24/2018, 1:52 PMDmitry Kandalov
01/04/2019, 5:46 PMkotlin.random.Random
? I want to use Random
in a test with random seed which I could print in case the test fails.karelpeeters
01/14/2019, 4:47 PM%
.Shawn
01/14/2019, 4:49 PM^
or |
alexfacciorusso
01/15/2019, 4:27 PMfun <T> Boolean.map(valueTrue: T, valueFalse: T): T = if(this) valueTrue else valueFalse
in the stdlib been already asked/taken into consideration?louiscad
01/17/2019, 9:12 AMcountIndexed
and sumByIndexed
to the stdlib. In an effort to remove a var
and a forEachIndexed
, I came across this need. However, I'd not want to bloat the stdlib. Please, add your ➕ if already needed one of these functions.Marc Knaup
01/28/2019, 12:37 PMjoinToString
parameter which allows something like that:
listOf(1,2,3,4).joinToString(separator = ", ", lastSeparator = " or ")
-> "1, 2, 3 or 4"
alexfacciorusso
01/28/2019, 2:18 PM.format
or .toString(decimals)
in the common stdlib?Marc Knaup
01/29/2019, 1:32 PMval <C : CharSequence> C.nonEmpty
get() = ifEmpty { null }
val <CollectionType : Collection<*>> CollectionType.nonEmpty
get() = ifEmpty { null }
val <Element> Array<Element>.nonEmpty
get() = ifEmpty { null }
val actualNonEmptyString = inputString?.nonEmpty ?: error("is required")
val actualNonEmptyList = inputList?.nonEmpty ?: error("is required")
Marc Knaup
01/30/2019, 9:15 AMhashMapOf()
by now but no toHashMap()
🙂gregorbg
02/09/2019, 2:49 PMMap<K, Set<T>>
or Map<K, Iterable<T>>
will also be perfectly fine, I'm mainly concerned about the grouping aspect and not the explicit return typerrader
02/14/2019, 4:06 PMOption
class? The use case https://youtrack.jetbrains.com/issue/KT-29026asad.awadia
03/03/2019, 1:37 AM[(1,2) , (3,4), (1,2)]
should return [(1,2),(3,4)]
PHondogo
03/03/2019, 7:30 AMTimmy
03/08/2019, 7:47 PMLinkedHashMap
does not have the accessOrder
property that the java.util.LinkedHashMap
has. Is there a replacement if I want to use such a functionality, for example for as a LRU cache? Or should I look for a third party library for simple LRU caching (with kotlin multiplatform support)?josephivie
03/09/2019, 6:53 AMinterface Comparator<T>
instead of interface Comparator<in T>
? Like, I know theoretically you shouldn't have to specify that the T
has in
variance, but in common code errors will be shown if you do something like interface Sort<in T>: Comparator<T>
, saying the T
in Comparator
is invariant
.rrader
03/13/2019, 11:00 AMlet
but for empty strings
someString?.let { calculate(it) }
I need someString.doIfNotEmpty { calculate(it) }
?asad.awadia
03/20/2019, 12:03 AMgregorbg
03/20/2019, 5:15 PMget
operator returning Nullable?
types for Maps but not for Lists? I understand that in a map, you may not know whether the key is set. But in a List, you may not know whether the index exists (i.e. the list is long enough) either??!asad.awadia
03/21/2019, 12:37 AMcreateHttpServer {
options = myServerOptionsObjectVariableFromAboveSomewhere
port = 8080
}
which should run effectively vertx().createHttpServer(options).listen(port)
?spand
03/25/2019, 12:48 PMException
and RuntimeException
? I can sort of see a compatibility argument but both are present even in commonpasssy
03/25/2019, 4:36 PMtoList
or toMap
. On the other hand asSequence
and asIterable
. From my testing the to
methods copy the collection where the as
methods create views on the data. Which means if the collections changes, the views also have access to the mutated data.
Is this a not documented rule? Would it be "wrong" if one of my own asCustomList
copies the data instead of creating a view? Should I call it toCustomList
?chan
03/31/2019, 8:33 AMKClass<*>
Dias
04/10/2019, 4:03 PMSeri
04/10/2019, 7:03 PMSeri
04/10/2019, 7:07 PMasad.awadia
04/16/2019, 12:20 PMLeoColman
04/16/2019, 4:48 PMChar.isDigit
to not have it's opposite Char.isNotDigit
?mkobit
04/19/2019, 6:27 PMSequence
based on attributes of the data?
for example, if i have
sequenceOf(1,2,3,5,6,8,10,14,15)
i'd like to "merge" contiguous elements together into a sequence that is
sequenceOf([1,2,3], [5,6], [8], [10], [14,15])
i'd like to retain the lazy evaluation, such that [1,2,3]
is yielded only when it is neededPere Casafont
04/29/2019, 9:44 AMMutableCollection::plusAssign(Iterable)
to compile without having assignment operators ambiguity error? Here an example that does not compile:
val list = listOf(1, 2, 3)
var mutableList = mutableListOf(4, 5, 6)
mutableList += list
Pere Casafont
04/29/2019, 9:44 AMMutableCollection::plusAssign(Iterable)
to compile without having assignment operators ambiguity error? Here an example that does not compile:
val list = listOf(1, 2, 3)
var mutableList = mutableListOf(4, 5, 6)
mutableList += list
gildor
04/29/2019, 9:49 AMvar
with val
If you need var
there, than use addAll instead:
mutableList.addAll(list)
Pere Casafont
04/29/2019, 10:07 AMplusAssign
had preference over plus
+ assign
to avoid this odd situationgildor
04/29/2019, 10:13 AMmutableList += list
is acutally reassign mutableList, but (mutableList + list) returns List, so type is not compatible, so it’s not clear how you can solve it