case class Meter(meters: Double) extends AnyVal
case class Gram(grams: Double) extends AnyVal
Value classes provide a type-safe way to encode units, even if they require a bit more characters to use them:
var length = Meter(3)
var weight = Gram(4)
//length = weight //type mismatch; found : Gr...