LoginSignup
0
0

More than 1 year has passed since last update.

【Kotlin】アルゴ式 標準出力 1-5(一日は何秒か)

Last updated at Posted at 2022-03-19

アルゴ式の「標準出力 1-5」を、
Kotlin の kotlin.time パッケージを使って解いてみた。

import kotlin.time.ExperimentalTime
import kotlin.time.days

@OptIn(ExperimentalTime::class)
fun main() {
    1.days.inWholeSeconds
        .also { println(it) }
}

アルゴ式の Kotlin はまだバージョン1.5のようだ。(正確なバージョンを確認する方法はあるのかな?)

Kotlin 1.6 だと次のように書ける。

Kotlin1.6
import kotlin.time.Duration.Companion.days

fun main() {
    1.days.inWholeSeconds
        .also { println(it) }
}

/以上

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0