• s

    Sam Stone

    5 months ago
    Does anyone know of a delegate like lazy that supports vars?
    s
    1 replies
    Copy to Clipboard
  • Klitos Kyriacou

    Klitos Kyriacou

    5 months ago
    When building a map, which of these two guidelines do you think is better:1. Use
    mapOf
    unless it has to be a hashmap, in which case use
    hashMapOf
    . 2. Use
    mapOf
    to document to your readers that entry order is important, or
    hashMapOf
    to document that order doesn't matter.
    Klitos Kyriacou
    Rob Elliot
    4 replies
    Copy to Clipboard
  • s

    Sam Stone

    5 months ago
    Any alternative to
    List.zip(List).toMap(mutableMapOf())
    ?
    s
    n
    +1
    17 replies
    Copy to Clipboard
  • s

    Sam Stone

    5 months ago
    Is
    MutableCollection.addAll(Collection/Iterable/Sequence/Array
    ) faster if the input and/or output are certain types of collections?
    s
    e
    15 replies
    Copy to Clipboard
  • s

    Sam Stone

    5 months ago
    Is the answer to that question just a Java question on the JVM? Are all Kotlin collections just aliases to Java collections? Or are there some Kotlin collections and the performance would be different for those?
    s
    e
    3 replies
    Copy to Clipboard
  • ghosalmartin

    ghosalmartin

    5 months ago
    Noticed this warning today,
    Non exhaustive 'when' statements on sealed class/interface will be prohibited in 1.7, add 'else' branch
    Does that mean using a sealed class/interface will no longer be exhaustive in a
    when
    . I thought that was a feature of ``sealed`?
    ghosalmartin
    e
    +2
    14 replies
    Copy to Clipboard
  • Adam Wilder

    Adam Wilder

    5 months ago
    Hey all, I have a best practices question regarding stdlib lists vs sequences. My understanding is when it comes to list builtins like map and filter, they will create a new list whereas sequences will lazily evaluate and combine the operations when appropriate. If I am using more than one of the collection builtins, should I always prefer to transform it to a sequence? Or combine them myself into one
    .mapNotNull
    if possible? Or is it strictly a judgement call based on the size of the data expected since iterating over a list of size 2 twice is really not a big deal
    Adam Wilder
    p
    +1
    5 replies
    Copy to Clipboard
  • christophsturm

    christophsturm

    5 months ago
    whats the best way to get an exhaustive map? (with an enum as a key). I could use a when and copy its output to a map with a utility method that calls the when for every key. is there a better way?
    christophsturm
    mcpiroman
    2 replies
    Copy to Clipboard
  • Chris Fillmore

    Chris Fillmore

    5 months ago
    Just curious, what is the motivation for
    kotlin.ranges.coerceAtLeast
    and
    kotlin.ranges.coerceAtMost
    , any reason these should be used in place of
    maxOf
    /
    minOf
    ? It surprises me that their implementation is not just
    Math.max
    and
    Math.min
    , but maybe I’m missing something!
    Chris Fillmore
    e
    3 replies
    Copy to Clipboard
  • Junjie Wu

    Junjie Wu

    5 months ago
    Is there any reason why
    Sequence<T>.drop(n: Int)
    param type is
    Int
    instead of
    Long
    ? I thought Kotlin’s sequence is equivalent to Java’s stream, and presuming the type should be the same as
    Stream<T> skip(long n);
    Junjie Wu
    r
    +1
    9 replies
    Copy to Clipboard