問題タブ [kotlin-native]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票する
2 に答える
357 参照

android - Android 固有部分の Kotlin/ネイティブ アクセス デバイス センサー

私は現在、非常に基本的だと思っていたタスクに行き詰まっています。iOS と Android の重力センサーを照会する必要がある Kotlin/Native のライブラリを開発しています。

ほとんどすべてのロジックは共通部分にあり、デバイス センサーとの通信だけがプラットフォーム固有のメソッドに実装されています。驚くべきことに、すべての iOS コア ライブラリ (この場合は CoreMotion) が移植されているため、実装は非常に簡単でした。

この場合、CoreMotion を使用すると、画面の向きが X、Y、または Z に関して変化するたびにコールバックを呼び出す重力センサーにリスナーを追加できます (私は Z に興味があります)。

Androidでは、私はこのようなことをします

しかし、必要なインポートは Kotlin/Native では利用できません

Kotlin/Native でこの種のハードウェア (重力センサー) にアクセスする方法はありますか? または、Kotlin/Native の Android 固有の部分の方が優れていますか?

0 投票する
2 に答える
3033 参照

kotlin - Kotlin ですべての入力行を読み取るクリーンな方法

コーディングの課題を行う際の一般的なパターンは、多くの行の入力を読み取ることです。行数が事前にわからないと仮定すると、EOF まで読み取る必要があります (readLine は null を返します)。

また、序文として、KotlinNative でコーディングしているため、java.utils.* に依存したくないため、スキャナーはありません。

私は多分次のようなことをしたいと思います

しかし、それは明らかに有効な Kotlin ではありません。私が思いつくことができる最もきれいなものは次のとおりです。

これは機能しますが、あまり慣用的ではないようです。while/break ループを使用せずに、すべての行を配列に読み込むより良い方法はありますか?

0 投票する
1 に答える
2165 参照

ios - kotlin.native.concurrent.InvalidMutabilityException: 凍結の突然変異の試み when using ktor in Kotlin Multiplatform (iOS)

I am trying to build a simple Kotlin Multiplatform app that calls to the internet to fetch some Strings from the intern

I am trying to build a simple Kotlin Multiplatform app that calls to the internet to fetch some Strings from the internet with ktor. I took some functions from Kotlin conference app which I compiled and it works fine on both Android and iOS.

However, in my sample app, it only works on Android, but on iOS it returns

kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen <object>@c422ffe8

Here is the GitHub repository and below is my code:

--

--

--


How recursive function control flow change for static variable?

I am trying to learn some stuff about recursive function and I try to run this

I am expecting that it will give me an output like this as similar to any local variable called in a recursive function.

But compiler gives me an output like this

I can't understand why this kind of output comes. Can anyone explain?