Measured now supports tons of Kotlin targets like iOS and all Apple platforms, Android Native, Linux, etc. So you can work with units of measure seamlessly no matter where you app runs.
Measured makes units of measure simple by providing intuitive, strongly-typed (i.e. compile-time enforced) units that combine using normal mathematical operations.
val velocity = 5 * meters / seconds
val acceleration = 9 * meters / (seconds * seconds)
val time = 1 * minutes
// d = vt + ½at²
val distance = velocity * time + 1.0 / 2 * acceleration * time * time
println(distance ) // 16500 m
println(distance `as` kilometers) // 16.5 km
println(distance `as` miles ) // 10.25262467191601 mi
println(5 * miles / hours `as` meters / seconds) // 2.2352 m/s
Top comments (0)