# Latest

**URL:** https://discuss.kotlinlang.org/latest.md?no_subcategories=false&page=3

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

**Page:** 4

---

## [LongRange.count() returns Int and cause an Exception](https://discuss.kotlinlang.org/t/longrange-count-returns-int-and-cause-an-exception/30878)

<div class="topic-metadata">

**Author:** [@przemek.materna](https://discuss.kotlinlang.org/u/przemek.materna)\
**Replies:** 7\
**Last updated:** [December 8, 2025, 10:53pm UTC](https://discuss.kotlinlang.org/t/longrange-count-returns-int-and-cause-an-exception/30878 "2025-12-08T22:53:03Z")

</div>

There is a LongRange, which exposes a method count(), by Iterable\<T\> extension: package kotlin.collections // file: \_Collections.kt public fun \<T\> Iterable\<T\>.count(): Int { if (this is Collection) return size …

---

## [What are the differences between Kotlin Multiplatform & Compose Multiplatform?](https://discuss.kotlinlang.org/t/what-are-the-differences-between-kotlin-multiplatform-compose-multiplatform/30865)

<div class="topic-metadata">

**Author:** [@dcs.79c](https://discuss.kotlinlang.org/u/dcs.79c)\
**Replies:** 5\
**Last updated:** [December 8, 2025, 9:04am UTC](https://discuss.kotlinlang.org/t/what-are-the-differences-between-kotlin-multiplatform-compose-multiplatform/30865 "2025-12-08T09:04:41Z")

</div>

I installed IntelliJ on my Mac. I have a book on Kotlin programming. I’m learning Kotlin! I’ve explored different programming languages - BASIC(before it became Visual Basic), Visual Basic, Turbo Pascal, & Java. Java is…

---

## [Weird and Unsolvable Exception](https://discuss.kotlinlang.org/t/weird-and-unsolvable-exception/30573)

<div class="topic-metadata">

**Author:** [@Abhiram\_Deshpande](https://discuss.kotlinlang.org/u/Abhiram_Deshpande)\
**Replies:** 11\
**Last updated:** [December 5, 2025, 7:59am UTC](https://discuss.kotlinlang.org/t/weird-and-unsolvable-exception/30573 "2025-12-05T07:59:16Z")

</div>

Hi. While developing an app on Android Studio ( Meerkat Feature Drop | 2024.3.2 Patch 1 ), everything was going fine till today morning when, in order to create a ViewModel and Relevant Factory, I created a class called …

---

## [I’d like to be able to plot trig functions & fractals & parametric equations on Kotlin](https://discuss.kotlinlang.org/t/i-d-like-to-be-able-to-plot-trig-functions-fractals-parametric-equations-on-kotlin/30867)

<div class="topic-metadata">

**Author:** [@dcs.79c](https://discuss.kotlinlang.org/u/dcs.79c)\
**Replies:** 3\
**Last updated:** [December 4, 2025, 8:46pm UTC](https://discuss.kotlinlang.org/t/i-d-like-to-be-able-to-plot-trig-functions-fractals-parametric-equations-on-kotlin/30867 "2025-12-04T20:46:56Z")

</div>

I’d like to be able to plot trig functions & fractals & parametric equations on Kotlin. I read about Let’s Plot. Back when Basic was Basic & not Visual Basic, I created programs that plotted parametric equations. It was …

---

## [Extra branches in the when statement (coverage)](https://discuss.kotlinlang.org/t/extra-branches-in-the-when-statement-coverage/30874)

<div class="topic-metadata">

**Author:** [@exfaust31](https://discuss.kotlinlang.org/u/exfaust31)\
**Replies:** 0\
**Last updated:** [December 3, 2025, 2:58pm UTC](https://discuss.kotlinlang.org/t/extra-branches-in-the-when-statement-coverage/30874 "2025-12-03T14:58:42Z")

</div>

Trying to get code coverage with a “when” expression using Kover or Intellij Coverage Plugin. There are always extra branches that prevent you from achieving 100% coverage. For example, the Intellij Coverage plugin and …

---

## [Having difficulty adapting the RabbitMQ client to coroutines](https://discuss.kotlinlang.org/t/having-difficulty-adapting-the-rabbitmq-client-to-coroutines/24163)

<div class="topic-metadata">

**Author:** [@mrpug](https://discuss.kotlinlang.org/u/mrpug)\
**Replies:** 6\
**Last updated:** [December 2, 2025, 3:25pm UTC](https://discuss.kotlinlang.org/t/having-difficulty-adapting-the-rabbitmq-client-to-coroutines/24163 "2025-12-02T15:25:53Z")

</div>

Hi all, I’m attempting to integrate a RabbitMQ consumer into a Kotlin project that uses coroutines heavily, but I’m having some issues adapting the RabbitMQ calls into coroutine calls. Has anyone done anything similar t…

---

## [Suggested new construct for tight code](https://discuss.kotlinlang.org/t/suggested-new-construct-for-tight-code/30866)

<div class="topic-metadata">

**Author:** [@digorydoo](https://discuss.kotlinlang.org/u/digorydoo)\
**Replies:** 3\
**Last updated:** [December 2, 2025, 6:42am UTC](https://discuss.kotlinlang.org/t/suggested-new-construct-for-tight-code/30866 "2025-12-02T06:42:41Z")

</div>

If you have an algorithm that is already O(n^2), that’s already bad. But if your inner loop creates new objects that need to be garbage-collected, that’s terrible! Here’s a suggestion how we could help both the programme…

---

## [Empty Main function](https://discuss.kotlinlang.org/t/empty-main-function/30864)

<div class="topic-metadata">

**Author:** [@dcs.79c](https://discuss.kotlinlang.org/u/dcs.79c)\
**Replies:** 2\
**Last updated:** [November 28, 2025, 4:07am UTC](https://discuss.kotlinlang.org/t/empty-main-function/30864 "2025-11-28T04:07:28Z")

</div>

I read online that the Main function is the starting point of the program. Is it possible to start a Kotlin program with an empty Main function, that is, fun Main(), & nothing else? I’m intrigued about Kotlin & I’m eag…

---

## [Why does takeIf allow nullable receivers in its predicate?](https://discuss.kotlinlang.org/t/why-does-takeif-allow-nullable-receivers-in-its-predicate/30863)

<div class="topic-metadata">

**Author:** [@fvasco](https://discuss.kotlinlang.org/u/fvasco)\
**Replies:** 0\
**Last updated:** [November 25, 2025, 1:25pm UTC](https://discuss.kotlinlang.org/t/why-does-takeif-allow-nullable-receivers-in-its-predicate/30863 "2025-11-25T13:25:45Z")

</div>

The signature of takeIf (and takeUnless) is: public inline fun \<T\> T.takeIf(predicate: (T) -\> Boolean): T? instead of: public inline fun \<T : Any\> T?.takeIf(predicate: (T) -\> Boolean): T? Why does Kotlin allow null a…

---

## [Make it easy to repeat something until it succeeds, but at most n times](https://discuss.kotlinlang.org/t/make-it-easy-to-repeat-something-until-it-succeeds-but-at-most-n-times/8097)

<div class="topic-metadata">

**Author:** [@dcuser](https://discuss.kotlinlang.org/u/dcuser)\
**Replies:** 13\
**Last updated:** [November 25, 2025, 12:56pm UTC](https://discuss.kotlinlang.org/t/make-it-easy-to-repeat-something-until-it-succeeds-but-at-most-n-times/8097 "2025-11-25T12:56:27Z")

</div>

These loops: for (i in 0..2) { doSomething() if(somethingFailed()) { continue } break } could maybe be expressed better. Something like this would be nice: try (maxTries = 3) { doSomething…

---

## [Parse Kotlin build.gradle.kts Script via ScriptDefinition](https://discuss.kotlinlang.org/t/parse-kotlin-build-gradle-kts-script-via-scriptdefinition/30862)

<div class="topic-metadata">

**Author:** [@PhilKes](https://discuss.kotlinlang.org/u/PhilKes)\
**Replies:** 0\
**Last updated:** [November 21, 2025, 11:29am UTC](https://discuss.kotlinlang.org/t/parse-kotlin-build-gradle-kts-script-via-scriptdefinition/30862 "2025-11-21T11:29:52Z")

</div>

Use Case: OpenRewrite is a tool to performce large-scale code migrations/refactorings which leverages parsing Java/Groovy/Kotlin sources and performing modifications on them. For Kotlin you can find the parsing code in…

---

## [JVM dependencies are not clear to me, esp. Regex](https://discuss.kotlinlang.org/t/jvm-dependencies-are-not-clear-to-me-esp-regex/30854)

<div class="topic-metadata">

**Author:** [@redflitzi](https://discuss.kotlinlang.org/u/redflitzi)\
**Replies:** 6\
**Last updated:** [November 21, 2025, 9:27am UTC](https://discuss.kotlinlang.org/t/jvm-dependencies-are-not-clear-to-me-esp-regex/30854 "2025-11-21T09:27:59Z")

</div>

Hi, as a Kotlin beginner, I am not sure what I can use when I want to create a JVM independent library. I try to use only the “Common part” of the documentation, as for my purposes this seems feasable avoiding implemen…

---

## [Capturing context parameter](https://discuss.kotlinlang.org/t/capturing-context-parameter/30859)

<div class="topic-metadata">

**Author:** [@msevcenko](https://discuss.kotlinlang.org/u/msevcenko)\
**Replies:** 2\
**Last updated:** [November 20, 2025, 9:19am UTC](https://discuss.kotlinlang.org/t/capturing-context-parameter/30859 "2025-11-20T09:19:59Z")

</div>

I am investigating the new feature of kotlin, Context parameters. In some edge situations, you may have a block of code that has accessible some context(s), which are however not directly accessible (not bound to any va…

---

## [Exposed-kotlin-datetime](https://discuss.kotlinlang.org/t/exposed-kotlin-datetime/22976)

<div class="topic-metadata">

**Author:** [@huggy](https://discuss.kotlinlang.org/u/huggy)\
**Replies:** 2\
**Last updated:** [November 19, 2025, 8:56am UTC](https://discuss.kotlinlang.org/t/exposed-kotlin-datetime/22976 "2025-11-19T08:56:12Z")

</div>

i see this module in the exposed source, yet i cannot find it in any maven repository. How can i use use this. The library basically lets us use the kotlin localdatetime instead of the java version.

---

## [Assignments as expressions](https://discuss.kotlinlang.org/t/assignments-as-expressions/1564)

<div class="topic-metadata">

**Author:** [@norswap](https://discuss.kotlinlang.org/u/norswap)\
**Replies:** 2\
**Last updated:** [November 12, 2025, 4:21pm UTC](https://discuss.kotlinlang.org/t/assignments-as-expressions/1564 "2025-11-12T16:21:27Z")

</div>

Is there a discussion or rational to forbidding using an assignment as an expression in Kotlin? I love the ability Kotin gives me write terse code, but this goes kind of contrary to that. I understand the risks, but so…

---

## [Segfault crash invoking kotlinc-native (konan)](https://discuss.kotlinlang.org/t/segfault-crash-invoking-kotlinc-native-konan/30852)

<div class="topic-metadata">

**Author:** [@abdillah](https://discuss.kotlinlang.org/u/abdillah)\
**Replies:** 0\
**Last updated:** [November 10, 2025, 11:19pm UTC](https://discuss.kotlinlang.org/t/segfault-crash-invoking-kotlinc-native-konan/30852 "2025-11-10T23:19:40Z")

</div>

Hello, I would like to use Kotlin as native language. So, I create a simple file and invoke a compiler: $ kotlinc-native -version Current kotlin-native dir: /nix/store/\<hash\>-kotlin-native-2.2.21 New writeable ko…

---

## [Null safety in javascript](https://discuss.kotlinlang.org/t/null-safety-in-javascript/6160)

<div class="topic-metadata">

**Author:** [@mattmook](https://discuss.kotlinlang.org/u/mattmook)\
**Replies:** 10\
**Last updated:** [November 10, 2025, 3:19pm UTC](https://discuss.kotlinlang.org/t/null-safety-in-javascript/6160 "2025-11-10T15:19:15Z")

</div>

I’ve started writing multi-platform modules and pretty quickly have started noticing some inconsistencies between JVM and JS and as such wanted to get a better understanding of what I should be doing. For example, given…

---

## [withContext breaks coroutine supervision](https://discuss.kotlinlang.org/t/withcontext-breaks-coroutine-supervision/30821)

<div class="topic-metadata">

**Author:** [@alexis](https://discuss.kotlinlang.org/u/alexis)\
**Replies:** 7\
**Last updated:** [November 9, 2025, 12:52pm UTC](https://discuss.kotlinlang.org/t/withcontext-breaks-coroutine-supervision/30821 "2025-11-09T12:52:38Z")

</div>

I have the following exception handler (just as example): class StatefulCoroutineExceptionHandler( private val logging: Boolean ) : CoroutineExceptionHandler { val throwables = mutableListOf\<Throwable\>() ov…

---

## [Using multiple KMP modules in Swift](https://discuss.kotlinlang.org/t/using-multiple-kmp-modules-in-swift/30834)

<div class="topic-metadata">

**Author:** [@tomektomek](https://discuss.kotlinlang.org/u/tomektomek)\
**Replies:** 0\
**Last updated:** [November 4, 2025, 6:43am UTC](https://discuss.kotlinlang.org/t/using-multiple-kmp-modules-in-swift/30834 "2025-11-04T06:43:30Z")

</div>

For simplicity’s sake let’s consider a following dependency graph: kmpA (depends on kmpB) kmpB (no deps) swiftC (depends on kmpA and swiftD) swiftD (depends on kmpB) I’m trying to pass an object of type X (declared in…

---

## [Problem of mutating data class for use in Jetpack Compose](https://discuss.kotlinlang.org/t/problem-of-mutating-data-class-for-use-in-jetpack-compose/30831)

<div class="topic-metadata">

**Author:** [@Injent](https://discuss.kotlinlang.org/u/Injent)\
**Replies:** 4\
**Last updated:** [November 2, 2025, 7:34pm UTC](https://discuss.kotlinlang.org/t/problem-of-mutating-data-class-for-use-in-jetpack-compose/30831 "2025-11-02T19:34:20Z")

</div>

The problem: The difficulty of maintaining the “stability” of large classes for Compose and mutability. The inevitability of the boilerplate code. I ran into the problem that Kotlin together with Jetpack Compose cannot…

---

## [Should I convert from Groovy DSL to Kotlin DSL?](https://discuss.kotlinlang.org/t/should-i-convert-from-groovy-dsl-to-kotlin-dsl/30806)

<div class="topic-metadata">

**Author:** [@elpafras](https://discuss.kotlinlang.org/u/elpafras)\
**Replies:** 3\
**Last updated:** [November 2, 2025, 6:10pm UTC](https://discuss.kotlinlang.org/t/should-i-convert-from-groovy-dsl-to-kotlin-dsl/30806 "2025-11-02T18:10:52Z")

</div>

I have an Android application with Groovy DSL. Should I convert it to Kotlin DSL, and does anyone know how to convert from Groovy to Kotlin?

---

## [Kotlinc native compiler - How to import "kotlinx.cinterop" to use "memScoped"?](https://discuss.kotlinlang.org/t/kotlinc-native-compiler-how-to-import-kotlinx-cinterop-to-use-memscoped/25816)

<div class="topic-metadata">

**Author:** [@umydwbp935](https://discuss.kotlinlang.org/u/umydwbp935)\
**Replies:** 1\
**Last updated:** [October 31, 2025, 9:42am UTC](https://discuss.kotlinlang.org/t/kotlinc-native-compiler-how-to-import-kotlinx-cinterop-to-use-memscoped/25816 "2025-10-31T09:42:52Z")

</div>

Hi there, I would like to write something like this: val fileSize = memScoped { val statBuf = alloc\<stat\>() val error = stat("/", statBuf.ptr) statBuf.st\_size } However, upon compilation I get: unresolved reference…

---

## [Unit is the worst naming](https://discuss.kotlinlang.org/t/unit-is-the-worst-naming/29843)

<div class="topic-metadata">

**Author:** [@CEO.Y](https://discuss.kotlinlang.org/u/CEO.Y)\
**Replies:** 40\
**Last updated:** [October 29, 2025, 1:38pm UTC](https://discuss.kotlinlang.org/t/unit-is-the-worst-naming/29843 "2025-10-29T13:38:37Z")

</div>

The word ‘unit’ is used very widely in the real world. For example, A Quantity class consists of ‘amount’ and ‘unit’. data class Unit( val code: String, val name: String, val symbol: String ) data class Qu…

---

## [What's an idiomatic way to name a function that takes \`() -\> Unit\` vs \`suspend () -\> Unit\`](https://discuss.kotlinlang.org/t/whats-an-idiomatic-way-to-name-a-function-that-takes-unit-vs-suspend-unit/30809)

<div class="topic-metadata">

**Author:** [@bp](https://discuss.kotlinlang.org/u/bp)\
**Replies:** 4\
**Last updated:** [October 28, 2025, 9:36pm UTC](https://discuss.kotlinlang.org/t/whats-an-idiomatic-way-to-name-a-function-that-takes-unit-vs-suspend-unit/30809 "2025-10-28T21:36:33Z")

</div>

I’m trying to get up to speed with Kotlin. One of the things I keep hitting snags with is how functions and suspend functions feel like oil and water and don’t mix. For example if I wanted to wrap some code like this: t…

---

## [How to use SQLite without GUI? only print console](https://discuss.kotlinlang.org/t/how-to-use-sqlite-without-gui-only-print-console/30803)

<div class="topic-metadata">

**Author:** [@vmercadolibretuc](https://discuss.kotlinlang.org/u/vmercadolibretuc)\
**Replies:** 4\
**Last updated:** [October 28, 2025, 12:43pm UTC](https://discuss.kotlinlang.org/t/how-to-use-sqlite-without-gui-only-print-console/30803 "2025-10-28T12:43:06Z")

</div>

With the GUI, everything is fine, but when I try to do it without the GUI, I get errors. Is this possible? I'm new to Kotlin. Thank you very much.

---

## [Union types](https://discuss.kotlinlang.org/t/union-types/77)

<div class="topic-metadata">

**Author:** [@salomonbrys](https://discuss.kotlinlang.org/u/salomonbrys)\
**Replies:** 141\
**Last updated:** [October 28, 2025, 8:59am UTC](https://discuss.kotlinlang.org/t/union-types/77 "2025-10-28T08:59:11Z")

</div>

I really like sealed types, and I would love for kotlin to support some kind of union type. e.g.: union JsonType { Boolean, Char, Number, String, JsonElement } public fun JsonObject.set(key: Stri…

---

## [A new feature for default arguments](https://discuss.kotlinlang.org/t/a-new-feature-for-default-arguments/30703)

<div class="topic-metadata">

**Author:** [@97jpfb](https://discuss.kotlinlang.org/u/97jpfb)\
**Replies:** 5\
**Last updated:** [October 27, 2025, 5:21pm UTC](https://discuss.kotlinlang.org/t/a-new-feature-for-default-arguments/30703 "2025-10-27T17:21:50Z")

</div>

Hello! Image a function that has a default argument. Is there a way to call this function with a certain argument if a condition is met, else use the default argument? Here’s some code: fun foo(arg: String = "Defaul…

---

## [Error on pausing / resuming / stoping the audio](https://discuss.kotlinlang.org/t/error-on-pausing-resuming-stoping-the-audio/30807)

<div class="topic-metadata">

**Author:** [@truebillionhari](https://discuss.kotlinlang.org/u/truebillionhari)\
**Replies:** 0\
**Last updated:** [October 27, 2025, 5:36am UTC](https://discuss.kotlinlang.org/t/error-on-pausing-resuming-stoping-the-audio/30807 "2025-10-27T05:36:21Z")

</div>

class AudioSource constructor ( context: Context ){ private val mediaRecorder = MediaRecorder(context) private val outputFile = File(context.getExternalFilesDir(Environment.DIRECTORY\_MUSIC),"sample.mp4") …

---

## [Use with finally](https://discuss.kotlinlang.org/t/use-with-finally/4848)

<div class="topic-metadata">

**Author:** [@benjishults](https://discuss.kotlinlang.org/u/benjishults)\
**Replies:** 5\
**Last updated:** [October 26, 2025, 11:58am UTC](https://discuss.kotlinlang.org/t/use-with-finally/4848 "2025-10-26T11:58:21Z")

</div>

The following would be nice: connection.use { // … } catch (e: UniquenessConstraintException) { // fix it } finally { // other stuff } I know “use” is currently a function and finally and catch are (soft) keyword…

---

## [Real-world health & posture app built with Compose Multiplatform + Ktor (Android, iOS, Backend)](https://discuss.kotlinlang.org/t/real-world-health-posture-app-built-with-compose-multiplatform-ktor-android-ios-backend/30801)

<div class="topic-metadata">

**Author:** [@til.pap](https://discuss.kotlinlang.org/u/til.pap)\
**Replies:** 0\
**Last updated:** [October 23, 2025, 8:34am UTC](https://discuss.kotlinlang.org/t/real-world-health-posture-app-built-with-compose-multiplatform-ktor-android-ios-backend/30801 "2025-10-23T08:34:00Z")

</div>

Hi everyone :waving\_hand: I wanted to share my production app StandProud — a real-world fitness app focused on posture correction and back-health improvement, built entirely with Compose Multiplatform and Ktor (Android,…

[Previous page](https://discuss.kotlinlang.org/latest.md?no_subcategories=false&page=2)

[Next page](https://discuss.kotlinlang.org/latest.md?no_subcategories=false&page=4)
