Ukraine has the right to return to all occupied territories and be reimbursed for all harm done by the invader. Help Ukraine to build fleet of Naval and Aerial drone with official President of Ukraine initiative ⇢ Ukraine has the right to return to all occupied territories and be reimbursed for all harm done by the invader. Help Ukraine to build fleet of Naval and Aerial drone with official Presid
検証環境 この記事の内容は、以下の環境で検証しました。 Intellij IDEA ULTIMATE 2018.2 Kotlin 1.3.0 Gradle Projectで作成 GradleファイルはKotlinで記述(KotlinでDSL) 準備 詳細は下記の準備を参照してください。 https://qiita.com/naoi/items/8abf2cddfc2cb3802daa Thread-local data 前回に引き続き、公式サイトを読み解いていきます。 今回のタイトルは、スレッドないのローカルのデータだと思いますが、意味不明です。 早速読み進めましょう。 Sometimes it is convenient to have an ability to pass some thread-local data, but, for coroutines, which are no
Enumをコード値から逆引きして作成したい状況はよくあるかと思います。 例えばDBの値とEnumのコード値が紐づいているときなどでしょうか。 実装方法 以下のようなcompanion objectを作成することで実装できます。 package hoge.constants enum class Animal( val dbParam: Int, val displayName: String ) { BIRD(0, "鳥"), BEAR(1, "熊"), HARE(2, "野ウサギ"), FISH(3, "魚"); companion object { fun getAnimalByDbParam(dbParam: Int): Animal = values().find { it.dbParam == dbParam } ?: throw NotFoundEnumException("A
[Kotlin]インライン関数を理解する(inline, noinline, crossinline)Kotlin はじめに Kotlinのインライン関数については公式リファレンスに説明があるのですが、 inlineやnoinline、crossinlineについては少し分かりづらい点がありました。 そこで実際にコードを書いてみてinlineやnoinline、crossinlineで何ができるか調べて行きたいと思います。 インライン化とは何か? インライン化とはインライン展開のことで、Wikipediaでは次のように説明されています。 インライン展開(インラインてんかい、英: inline expansion または 英: inlining)とは、コンパイラによる最適化手法の1つで、 関数を呼び出す側に呼び出される関数のコードを展開し、関数への制御転送をしないようにする手法。これにより関
はじめに この記事は Kotlin Advent Calendar 21日目の記事です。 Kotlin Advent Calendarは3年連続3回目の参加になります。 今年はGoogle I/OでKotlinがAndroidに正式採用されて、酉年の2017年はKotlin🐤にとっても飛躍の年になりました! 11月にはサンフランシスコにてKotlin Confが開催され、更なる盛り上がりを見せています! また、レビュアーという形ですがKotlin In Actionの翻訳に携わりKotlinの盛り上げに少しばかりは貢献できたのではないかと思います。 本記事ではそのKotlin In Actionの著者の1人であるSvetlana Isakova氏のKotlin Confでのセッション 「Kotlin Types: Exposed」の内容と、Kotlin In Actionの6章の内容を元
Kotlin には標準ライブラリが用意されており、その中にコレクションも存在する。 特徴 Kotlin のコレクションは、「読み取り専用」と「書き込み可」のインターフェースが明確に分かれている。 listOf(), mapOf() など、関数でインスタンスを生成する。 Stream API に用意されているような filter() などのメソッドが、 Iterable などに定義されている。 コレクションの種類 List Map Set インターフェースの関係 kotlin.collections パッケージの下にある各インターフェースがどのような関係になっているのか、クラス図で表現した。 基本は JDK のコレクションと同じ構成だが、 MutableIterable など書き込み可能かどうかを区別するためにインターフェースが追加されている。 List などの Mutable が付いていな
Coroutines always execute in some context represented by a value of the CoroutineContext type, defined in the Kotlin standard library. The coroutine context is a set of various elements. The main elements are the Job of the coroutine, which we've seen before, and its dispatcher, which is covered in this section. Dispatchers and threadsThe coroutine context includes a coroutine dispatcher (see Coro
Going Reactive with Spring, Coroutines and Kotlin Flow Since we announced Spring Framework official support for Kotlin in January 2017, a lot of things happened. Kotlin was announced as an official Android development language at Google I/O 2017, we continued to improve the Kotlin support across Spring portfolio and Kotlin itself has continued to evolve with key new features like coroutines. I wou
Structured concurrency in Kotlin Coroutines requires developers to always launch coroutines in the context of CoroutineScope or to specify a scope explicitly. It seems that using GlobalScope is a good default for launching work in background, however we do not recommend using GlobalScope. Why? Let us see it with an example. Suppose that we have some CPU-consuming or IO-bound blocking task which ta
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く