All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.io.nacular.measured.units.Mass.kt Maven / Gradle / Ivy

There is a newer version: 0.4.1
Show newest version
package io.nacular.measured.units

/**
 * Units to measure how much matter is in an object.
 */
open class Mass(suffix: String, ratio: Double = 1.0): Units(suffix, ratio) {
    operator fun div(other: Mass) = ratio / other.ratio

    companion object {
        val kilograms = Mass("kg")
        val grams     = Mass("g", 1.0 / 1000)
    }
}

operator fun Length.times(mass: Mass) = mass * this
operator fun Measure.times(mass: Mass) = amount * (units * mass)




© 2015 - 2025 Weber Informatics LLC | Privacy Policy