top | item 34282926

(no title)

dima_vm | 3 years ago

You can make that in Kotlin, e.g.: `3.mph` or `(-45..45).deg` for ranges.

with definition like:

    val Double.mph: Speed
      get() = Speed.mph(this)

    data class Speed(val ms: Double)
      companion object {
        fun mph(mph: Double) = Speed(mph * 1609.344 / 3600.0)
      }

discuss

order

No comments yet.