• e

    elect

    1 year ago
    sumOf{..}: Float
    , there are Int, Long, UInt, ULong, Double, BigDecimal, BigInteger but Float is missing
    e
    elizarov
    18 replies
    Copy to Clipboard
  • h

    holgerbrandl

    1 year ago
    In what situations may
    Number.toDouble()
    "involve rounding" as suggested by its API docs?
    h
    e
    +1
    11 replies
    Copy to Clipboard
  • poohbar

    poohbar

    1 year ago
    Is there any chance Kotlin could "synthetize" named arguments for Java libraries? Some libraries I use take many arguments of the same type so order matters. It would be great if I could explicitly name the arguments.
    poohbar
    j
    +1
    4 replies
    Copy to Clipboard
  • n

    nkiesel

    1 year ago
    Why do we not have a
    buildString
    which takes a separator as an optional parameter? Right now I use e.g.
    buildList { ... add(..) }.joinToString(" ")
    but
    buildString(" ") { ... add(...) }
    would be nicer. And perhaps also supports the "prefix" and "suffix" from Java's
    StringJoiner
    ?
    n
    louiscad
    +1
    3 replies
    Copy to Clipboard
  • a

    Abduqodiri Qurbonzoda [JB]

    1 year ago
    Hi everyone! Please share your feedback on this proposal: https://github.com/Kotlin/KEEP/issues/227
    a
    1 replies
    Copy to Clipboard
  • tapchicoma

    tapchicoma

    1 year ago
    With regard to new
    java.nio.file.Path
    extensions in stdlib will it make sense to add new
    PathTreeWalk
    class similar to
    FileTreeWalk
    ? I know nio has
    walkFileTree()
    method, but it does not produces
    Sequence
    .
    tapchicoma
    1 replies
    Copy to Clipboard
  • Derek Peirce

    Derek Peirce

    1 year ago
    I propose adding the following method to the stdlib:
    public inline fun <T1, T2: Comparable<T2>> compareBy(crossinline selector: (T1) -> T2): Comparator<T1> =
            Comparator { a, b -> selector(a).compareTo(selector(b)) }
    This looks similar to the existing compareBy:
    public inline fun <T> compareBy(crossinline selector: (T) -> Comparable<*>?): Comparator<T> =
        Comparator { a, b -> compareValuesBy(a, b, selector) }
    But the type ambiguity and nullability make it inefficient, as it needs to box primitives. I ran a benchmark comparing the two
    compareBy
    implementations for finding the maximum of100,000 objects by their random int fields, and got these results:
    Benchmark                                           (N)  Mode  Cnt  Score   Error  Units
    ComparatorBenchmarkPrimitiveHelper.maxKt         100000  avgt   10  2.824 ± 0.102  ms/op
    ComparatorBenchmarkPrimitiveHelper.maxPrimitive  100000  avgt   10  0.381 ± 0.155  ms/op
    The results speak for themselves, the mass boxing and unboxing in the existing implementation has major performance implications and ought to be prevented with a more specialized
    compareBy
    method. This naturally extends to the methods that use it such as
    sortBy
    and
    sortedBy
    (I ran the benchmark using
    maxBy
    because it gave the most contrast,
    sortBy
    spent more time on intermediate operations). Strangely,
    maxBy
    and similar already require non-null values and work as they are.
    Derek Peirce
    ilya.gorbunov
    3 replies
    Copy to Clipboard
  • m

    Marc Knaup

    1 year ago
    Suggestion:
    ClosedRange<T>.mapBounds()
    val range = 1 .. 10
    val shiftedRange = range.mapBounds { it + 10 } // = 11 .. 20
    val characters = "a" .. "z"
    val uppercaseCharacters = characters.mapBounds { it.toUpperCase() } // == "A" .. "Z"
    fun <T : Comparable<T>, R : Comparable<R>> ClosedRange<T>.mapBounds(transform: (T) -> R): ClosedRange<R> =
        transform(start) .. transform(endInclusive)
    
    // plus overloads for primitive ranges
    m
    a
    7 replies
    Copy to Clipboard
  • s

    Slackbot

    1 year ago
    This message was deleted.
    s
    1 replies
    Copy to Clipboard
  • b

    Ben

    1 year ago
    Not sure if this is where to ask but how do we handle delegation with default methods. It seems kotlin tries to call the default method on the interface instead of the passed in implementation. This is with a java interface and java final implementation (AWS SqsAsyncClient and DefaultSqsAsyncClient). I would have assumed that the method would be called on the java implementation first.
    b
    m
    3 replies
    Copy to Clipboard