# Libraries

**URL:** https://discuss.kotlinlang.org/c/libraries/11.md?page=1

[Latest](https://discuss.kotlinlang.org/latest.md) · [Categories](https://discuss.kotlinlang.org/categories.md)

**Page:** 2

---

## [Functions to manipulate ranges](https://discuss.kotlinlang.org/t/functions-to-manipulate-ranges/21571)

<div class="topic-metadata">

**Author:** [@dmitry](https://discuss.kotlinlang.org/u/dmitry)\
**Replies:** 1\
**Last updated:** [July 25, 2024, 1:20pm UTC](https://discuss.kotlinlang.org/t/functions-to-manipulate-ranges/21571 "2024-07-25T13:20:31Z")

</div>

Currently there are no methods to transform or combine ranges. Either you need to manually create a new range instance by coping all parameters, including the step of the IntProgression, even if the step didn’t change, e…

---

## [Should Array have a getOrPut method?](https://discuss.kotlinlang.org/t/should-array-have-a-getorput-method/28791)

<div class="topic-metadata">

**Author:** [@brian.dastous](https://discuss.kotlinlang.org/u/brian.dastous)\
**Replies:** 3\
**Last updated:** [June 27, 2024, 6:47am UTC](https://discuss.kotlinlang.org/t/should-array-have-a-getorput-method/28791 "2024-06-27T06:47:01Z")

</div>

Arrays are often used as maps in the case where you have a relatively small number of integer keys. It seems like it would be useful to have a getOrPut method similar to that available for maps. The only interesting nuan…

---

## [Kotlinx serialization: I got "NoSuchElementException: List is empty. " when Properties.encodeToMap](https://discuss.kotlinlang.org/t/kotlinx-serialization-i-got-nosuchelementexception-list-is-empty-when-properties-encodetomap/28692)

<div class="topic-metadata">

**Author:** [@toyokazu.ohara](https://discuss.kotlinlang.org/u/toyokazu.ohara)\
**Replies:** 1\
**Last updated:** [May 30, 2024, 6:40pm UTC](https://discuss.kotlinlang.org/t/kotlinx-serialization-i-got-nosuchelementexception-list-is-empty-when-properties-encodetomap/28692 "2024-05-30T18:40:48Z")

</div>

I got an exception when invoking Properties.encodeToMap Is it expected behavior? sample code id below. @Serializable class Data (val prop: String) val data: Data? = Data("prop") println(Json.encodeToSt…

---

## [Kotlin 2.0.0 - Suspension functions can only be called within coroutine body](https://discuss.kotlinlang.org/t/kotlin-2-0-0-suspension-functions-can-only-be-called-within-coroutine-body/28650)

<div class="topic-metadata">

**Author:** [@vullnetlimani](https://discuss.kotlinlang.org/u/vullnetlimani)\
**Replies:** 1\
**Last updated:** [May 28, 2024, 5:00pm UTC](https://discuss.kotlinlang.org/t/kotlin-2-0-0-suspension-functions-can-only-be-called-within-coroutine-body/28650 "2024-05-28T17:00:44Z")

</div>

I’m facing an issue with invoking weakReferenceTask, which represents a suspended function in Kotlin 1.9.24. Previously, I could call withContext or other suspension functions without any problems. However, after updati…

---

## [\-10.floorDiv(4) returns -2, expected -3](https://discuss.kotlinlang.org/t/10-floordiv-4-returns-2-expected-3/28627)

<div class="topic-metadata">

**Author:** [@bwb](https://discuss.kotlinlang.org/u/bwb)\
**Replies:** 2\
**Last updated:** [May 18, 2024, 1:29am UTC](https://discuss.kotlinlang.org/t/10-floordiv-4-returns-2-expected-3/28627 "2024-05-18T01:29:14Z")

</div>

While working my way through the Kotlin docs I stopped to browse Kotlin’s standard library, writing tiny programs to to test my understanding of standard library features. Floor division surprised me. // Intellij IDEA 2…

---

## [Trouble with corotines flow buffer](https://discuss.kotlinlang.org/t/trouble-with-corotines-flow-buffer/28547)

<div class="topic-metadata">

**Author:** [@spersels](https://discuss.kotlinlang.org/u/spersels)\
**Replies:** 1\
**Last updated:** [May 2, 2024, 12:07am UTC](https://discuss.kotlinlang.org/t/trouble-with-corotines-flow-buffer/28547 "2024-05-02T00:07:08Z")

</div>

Very simple test program to try to understand coroutines and flows and buffereing. Maint.kt: package org.gvs.testflows import kotlinx.coroutines.\* import kotlinx.coroutines.flow.\* import kotlinx.coroutines.flow.buffer…

---

## [High-quality documentation for my ORM framework is completed](https://discuss.kotlinlang.org/t/high-quality-documentation-for-my-orm-framework-is-completed/27422)

<div class="topic-metadata">

**Author:** [@babyfish-ct](https://discuss.kotlinlang.org/u/babyfish-ct)\
**Replies:** 7\
**Last updated:** [March 29, 2024, 6:07pm UTC](https://discuss.kotlinlang.org/t/high-quality-documentation-for-my-orm-framework-is-completed/27422 "2024-03-29T18:07:20Z")

</div>

Hello everyone, The high-quality documentation for my ORM framework is now complete: Jimmer, revolutionary ORM for java & kotlin Based on suggestions from a group of Jimmer users, I spent a full four months writing thi…

---

## [Why can't SharedFlows be completable?](https://discuss.kotlinlang.org/t/why-cant-sharedflows-be-completable/28374)

<div class="topic-metadata">

**Author:** [@mashal](https://discuss.kotlinlang.org/u/mashal)\
**Replies:** 1\
**Last updated:** [March 27, 2024, 12:02am UTC](https://discuss.kotlinlang.org/t/why-cant-sharedflows-be-completable/28374 "2024-03-27T00:02:03Z")

</div>

I really don’t understand why SharedFlows can’t (or shouldn’t) be completable? I’ve encountered many situations were I needed a completable sharedflow. For instance imagine you’re writing a download manager that can hand…

---

## [Feature Request: MutableStateFlow - support equalsPolicy{}](https://discuss.kotlinlang.org/t/feature-request-mutablestateflow-support-equalspolicy/28017)

<div class="topic-metadata">

**Author:** [@reemh](https://discuss.kotlinlang.org/u/reemh)\
**Replies:** 8\
**Last updated:** [February 15, 2024, 12:46pm UTC](https://discuss.kotlinlang.org/t/feature-request-mutablestateflow-support-equalspolicy/28017 "2024-02-15T12:46:30Z")

</div>

saying I have a data class MyHeavyDataClass(...) “heavy” data class with multiple fields / nested fields / anything that would cause MyHeavyDataClass::equals() to run in non-trivial perfomance-hitting duration. now let’…

---

## [Selfie: a new kind of snapshot testing library for Kotlin Multiplatform](https://discuss.kotlinlang.org/t/selfie-a-new-kind-of-snapshot-testing-library-for-kotlin-multiplatform/27981)

<div class="topic-metadata">

**Author:** [@nedtwigg](https://discuss.kotlinlang.org/u/nedtwigg)\
**Replies:** 1\
**Last updated:** [January 20, 2024, 6:20am UTC](https://discuss.kotlinlang.org/t/selfie-a-new-kind-of-snapshot-testing-library-for-kotlin-multiplatform/27981 "2024-01-20T06:20:00Z")

</div>

Snapshot testing has been badly underused for three reasons: controlling read vs write used to be cumbersome (fixed by control comments) stale snapshots used to pile up (fixed by garbage collection) a great test should…

---

## [Coroutines That Call Functions With Blocking Code](https://discuss.kotlinlang.org/t/coroutines-that-call-functions-with-blocking-code/27478)

<div class="topic-metadata">

**Author:** [@william.may.jr](https://discuss.kotlinlang.org/u/william.may.jr)\
**Replies:** 17\
**Last updated:** [December 21, 2023, 5:01am UTC](https://discuss.kotlinlang.org/t/coroutines-that-call-functions-with-blocking-code/27478 "2023-12-21T05:01:10Z")

</div>

I’m trying to confirm if my understanding of coroutines is correct. Given that: methodThatContainsBlockingCode(i) calls some sort of blocking code, be it jdbc, REST call, etc… Then 10 lightweight threads will be create…

---

## [Please help understand coroutine launch](https://discuss.kotlinlang.org/t/please-help-understand-coroutine-launch/27805)

<div class="topic-metadata">

**Author:** [@patrickz2014](https://discuss.kotlinlang.org/u/patrickz2014)\
**Replies:** 2\
**Last updated:** [December 16, 2023, 6:16am UTC](https://discuss.kotlinlang.org/t/please-help-understand-coroutine-launch/27805 "2023-12-16T06:16:32Z")

</div>

Hello, could you help me understand what’s the different between the below codes. Thanks. What’s the fundamental different between using scope.launch and launch inside a launch? fun main() { val scope = CoroutineScope(…

---

## [Implementing a Zero-Cost Random Picker in Kotlin Sequences](https://discuss.kotlinlang.org/t/implementing-a-zero-cost-random-picker-in-kotlin-sequences/27772)

<div class="topic-metadata">

**Author:** [@chopin.frederic.sui](https://discuss.kotlinlang.org/u/chopin.frederic.sui)\
**Replies:** 2\
**Last updated:** [December 8, 2023, 11:24am UTC](https://discuss.kotlinlang.org/t/implementing-a-zero-cost-random-picker-in-kotlin-sequences/27772 "2023-12-08T11:24:22Z")

</div>

---

## [Is it possible to use multiple base url at runtime with Retrofit?](https://discuss.kotlinlang.org/t/is-it-possible-to-use-multiple-base-url-at-runtime-with-retrofit/27695)

<div class="topic-metadata">

**Author:** [@Dontsu](https://discuss.kotlinlang.org/u/Dontsu)\
**Replies:** 3\
**Last updated:** [November 28, 2023, 6:50am UTC](https://discuss.kotlinlang.org/t/is-it-possible-to-use-multiple-base-url-at-runtime-with-retrofit/27695 "2023-11-28T06:50:57Z")

</div>

I have two base url. So, i made 2 Retrofit instance. But i’m just wondering it’s possible to use multiple base urls within a Retrofit instance without using @Url.

---

## [Head-tail splitting for sequences: avoid re-entering sequence generator without casting Sequence to Iterator?](https://discuss.kotlinlang.org/t/head-tail-splitting-for-sequences-avoid-re-entering-sequence-generator-without-casting-sequence-to-iterator/27420)

<div class="topic-metadata">

**Author:** [@neurosurg](https://discuss.kotlinlang.org/u/neurosurg)\
**Replies:** 5\
**Last updated:** [September 22, 2023, 8:12am UTC](https://discuss.kotlinlang.org/t/head-tail-splitting-for-sequences-avoid-re-entering-sequence-generator-without-casting-sequence-to-iterator/27420 "2023-09-22T08:12:25Z")

</div>

Hi let’s imagine a Sequence instance is given and we want to split it into a pair consisting of sequence’s head element and the tail rest of the sequence. Q: Is it possible to implement such thing without casting Seque…

---

## [Ever faced challenges with architectural linting in your projects? I think I have solved this issue with ArchUnit for Kotlin](https://discuss.kotlinlang.org/t/ever-faced-challenges-with-architectural-linting-in-your-projects-i-think-i-have-solved-this-issue-with-archunit-for-kotlin/27368)

<div class="topic-metadata">

**Author:** [@panel](https://discuss.kotlinlang.org/u/panel)\
**Replies:** 1\
**Last updated:** [September 18, 2023, 10:54pm UTC](https://discuss.kotlinlang.org/t/ever-faced-challenges-with-architectural-linting-in-your-projects-i-think-i-have-solved-this-issue-with-archunit-for-kotlin/27368 "2023-09-18T22:54:16Z")

</div>

I have built a new linter - it got a lot of community attention, but it needs community input to polish it. In a repo, you will find samples, extensive documentation, and a few articles. Let me know what you think

---

## [Coroutines for low latency/zero gc software](https://discuss.kotlinlang.org/t/coroutines-for-low-latency-zero-gc-software/26450)

<div class="topic-metadata">

**Author:** [@vach](https://discuss.kotlinlang.org/u/vach)\
**Replies:** 29\
**Last updated:** [September 3, 2023, 7:36pm UTC](https://discuss.kotlinlang.org/t/coroutines-for-low-latency-zero-gc-software/26450 "2023-09-03T19:36:03Z")

</div>

I’ts been few years since i last used coroutines, nowdays i’m doing low latency and zero gc software, essentially systems where once application is bootstraped and jvm warmed up no objects are to be created especially on…

---

## [Kotlin TestImplementation slowing down execution by 25%](https://discuss.kotlinlang.org/t/kotlin-testimplementation-slowing-down-execution-by-25/27250)

<div class="topic-metadata">

**Author:** [@gunnarb](https://discuss.kotlinlang.org/u/gunnarb)\
**Replies:** 2\
**Last updated:** [August 17, 2023, 9:16pm UTC](https://discuss.kotlinlang.org/t/kotlin-testimplementation-slowing-down-execution-by-25/27250 "2023-08-17T21:16:40Z")

</div>

I have a little program calculating on a np-hard problem, so the most execution time is generated in math calculations. I never took much attention to the “testImplementation(“org.jetbrains.kotlin:kotlin-test-junit:1.9.…

---

## [ClosedRange to Sequence](https://discuss.kotlinlang.org/t/closedrange-to-sequence/18782)

<div class="topic-metadata">

**Author:** [@imanushin](https://discuss.kotlinlang.org/u/imanushin)\
**Replies:** 3\
**Last updated:** [August 15, 2023, 9:19pm UTC](https://discuss.kotlinlang.org/t/closedrange-to-sequence/18782 "2023-08-15T21:19:32Z")

</div>

Hello, What do you think is it worth adding the following extension to the Kotlin Library? fun \<T\> ClosedRange\<T\>.toSequence(nextItem: (T) -\> (T)) : Sequence\<T\> { generateSequence(nextItem.start) { prev -\> …

---

## [Announcing kotlinx-metadata-jvm library for reading/modifying metadata of Kotlin/JVM class files](https://discuss.kotlinlang.org/t/announcing-kotlinx-metadata-jvm-library-for-reading-modifying-metadata-of-kotlin-jvm-class-files/7980)

<div class="topic-metadata">

**Author:** [@udalov](https://discuss.kotlinlang.org/u/udalov)\
**Replies:** 53\
**Last updated:** [August 1, 2023, 2:58pm UTC](https://discuss.kotlinlang.org/t/announcing-kotlinx-metadata-jvm-library-for-reading-modifying-metadata-of-kotlin-jvm-class-files/7980 "2023-08-01T14:58:51Z")

</div>

Please welcome a new library kotlinx-metadata-jvm designed for tools that need to read or modify the Kotlin metadata, such as bytecode obfuscators and annotation processors. With kotlinx-metadata-jvm, it’s possible to ma…

---

## [Json serialization with limited memory consumption](https://discuss.kotlinlang.org/t/json-serialization-with-limited-memory-consumption/27134)

<div class="topic-metadata">

**Author:** [@Psijic](https://discuss.kotlinlang.org/u/Psijic)\
**Replies:** 17\
**Last updated:** [July 29, 2023, 8:13pm UTC](https://discuss.kotlinlang.org/t/json-serialization-with-limited-memory-consumption/27134 "2023-07-29T20:13:00Z")

</div>

I have a simple decoder val json = Json { ignoreUnknownKeys = true } return jsonString?.let { json.decodeFromString\<List\<T\>\>(it) } that works well until I got an error: Fatal Exception: java.lang.Out…

---

## [Rationale behind awaitAll's error handling?](https://discuss.kotlinlang.org/t/rationale-behind-awaitalls-error-handling/26417)

<div class="topic-metadata">

**Author:** [@smorescoder](https://discuss.kotlinlang.org/u/smorescoder)\
**Replies:** 3\
**Last updated:** [July 26, 2023, 9:08am UTC](https://discuss.kotlinlang.org/t/rationale-behind-awaitalls-error-handling/26417 "2023-07-26T09:08:17Z")

</div>

I’m noticing some counter-intuitive error-handling behavior when using awaitAll. For example: suspend fun main(): Unit = coroutineScope { val deferred = async { throw Exception("fake") } try { listOf(deferred).a…

---

## [Help getting Compose Multiplatform working with Maven](https://discuss.kotlinlang.org/t/help-getting-compose-multiplatform-working-with-maven/26095)

<div class="topic-metadata">

**Author:** [@Skater901](https://discuss.kotlinlang.org/u/Skater901)\
**Replies:** 3\
**Last updated:** [July 19, 2023, 10:44pm UTC](https://discuss.kotlinlang.org/t/help-getting-compose-multiplatform-working-with-maven/26095 "2023-07-19T22:44:10Z")

</div>

Hi all, first time posting here, good to be here. :slight\_smile: I hope this topic is in the right category; please move if not. As the title says, I’m after some help on getting Compose Multiplatform to work with Mave…

---

## [Are flows/coroutines slow?](https://discuss.kotlinlang.org/t/are-flows-coroutines-slow/26955)

<div class="topic-metadata">

**Author:** [@fedorov1984](https://discuss.kotlinlang.org/u/fedorov1984)\
**Replies:** 5\
**Last updated:** [July 16, 2023, 3:50pm UTC](https://discuss.kotlinlang.org/t/are-flows-coroutines-slow/26955 "2023-07-16T15:50:02Z")

</div>

I am observing slow performance from coroutines/flows. Here is the snippet private suspend fun Collection\<Solver\>.solve(context) = coroutineScope { val channel = produce { forEach { …

---

## [Kotlinx DelayWithTimeoutDiagnostics not found?](https://discuss.kotlinlang.org/t/kotlinx-delaywithtimeoutdiagnostics-not-found/27020)

<div class="topic-metadata">

**Author:** [@alexandre.herbreteau](https://discuss.kotlinlang.org/u/alexandre.herbreteau)\
**Replies:** 1\
**Last updated:** [July 15, 2023, 8:35pm UTC](https://discuss.kotlinlang.org/t/kotlinx-delaywithtimeoutdiagnostics-not-found/27020 "2023-07-15T20:35:08Z")

</div>

Hi all, I’m using “runTest” from kotlinx.coroutines.test and I’ve got this exception at runtime: java.lang.NoClassDefFoundError: kotlinx.coroutines.DelayWithTimeoutDiagnostics I’m using last Kotlin 1.8.2 and last Kotl…

---

## [Kotlinx.serialization - serialize/apply only changes](https://discuss.kotlinlang.org/t/kotlinx-serialization-serialize-apply-only-changes/26940)

<div class="topic-metadata">

**Author:** [@tothiz](https://discuss.kotlinlang.org/u/tothiz)\
**Replies:** 4\
**Last updated:** [June 16, 2023, 1:17pm UTC](https://discuss.kotlinlang.org/t/kotlinx-serialization-serialize-apply-only-changes/26940 "2023-06-16T13:17:09Z")

</div>

Is there a way to serialize only the changes made on an instance and then apply the changes on another instance, assuming the starting point of the two instances are the same? Something like this: class Data(var value …

---

## [Ktor + FTP](https://discuss.kotlinlang.org/t/ktor-ftp/26911)

<div class="topic-metadata">

**Author:** [@Psijic](https://discuss.kotlinlang.org/u/Psijic)\
**Replies:** 1\
**Last updated:** [June 8, 2023, 8:15am UTC](https://discuss.kotlinlang.org/t/ktor-ftp/26911 "2023-06-08T08:15:51Z")

</div>

Is it possible to use Ktor to upload files via FTP? Or is it possible in Kotlin by default?

---

## [Coroutine select - need onJoin or onAwait that cancels if not chosen?](https://discuss.kotlinlang.org/t/coroutine-select-need-onjoin-or-onawait-that-cancels-if-not-chosen/26457)

<div class="topic-metadata">

**Author:** [@frizzil](https://discuss.kotlinlang.org/u/frizzil)\
**Replies:** 2\
**Last updated:** [June 8, 2023, 7:17am UTC](https://discuss.kotlinlang.org/t/coroutine-select-need-onjoin-or-onawait-that-cancels-if-not-chosen/26457 "2023-06-08T07:17:59Z")

</div>

If I’m not mistaken, calling onJoin on a Job inside select will NOT result in the job being canceled if another clause is chosen (same with onAwait.) However, this is absolutely functionality I will regularly use in the …

---

## [Publishing an application on play store....licenses and royalties doubts](https://discuss.kotlinlang.org/t/publishing-an-application-on-play-store-licenses-and-royalties-doubts/26899)

<div class="topic-metadata">

**Author:** [@Massimo\_Cordisco](https://discuss.kotlinlang.org/u/Massimo_Cordisco)\
**Replies:** 1\
**Last updated:** [June 6, 2023, 7:35pm UTC](https://discuss.kotlinlang.org/t/publishing-an-application-on-play-store-licenses-and-royalties-doubts/26899 "2023-06-06T19:35:05Z")

</div>

i’ve build an android application in Kotlin, and it use these libraries : implementation "androidx.camera:camera-core:${camerax\_version}" implementation "androidx.camera:camera-camera2:${camerax\_version}" i…

---

## [Unpredictable tatal exception in kotlinx.coroutines internal machinery with Ktor](https://discuss.kotlinlang.org/t/unpredictable-tatal-exception-in-kotlinx-coroutines-internal-machinery-with-ktor/26893)

<div class="topic-metadata">

**Author:** [@tmpod](https://discuss.kotlinlang.org/u/tmpod)\
**Replies:** 1\
**Last updated:** [June 4, 2023, 8:51pm UTC](https://discuss.kotlinlang.org/t/unpredictable-tatal-exception-in-kotlinx-coroutines-internal-machinery-with-ktor/26893 "2023-06-04T20:51:36Z")

</div>

Hello, I’ve been having a really strange issue for a bit now, related to kotlinx.coroutines and Ktor which I can’t reliably reproduce, let alone start to debug and understand. It happens, seemingly at random, although …

[Previous page](https://discuss.kotlinlang.org/c/libraries/11.md)

[Next page](https://discuss.kotlinlang.org/c/libraries/11.md?page=2)
