Skip to content
zzorn edited this page Sep 14, 2010 · 8 revisions

ScalaQuantity type checks expressions using physical units on compile time for unit assignment correctness.

Usage example of ScalaQuantity:


import scalaquantity.Units._

object VelociraptorTest {
  def main(args: Array[String]) {

    val velociraptorSpeed = 25 * m / s
    val humanRunningSpeed = 10 * km / h
    val distance = 30 * feet

    val humanRemainingLifeTime: Time = distance / (velociraptorSpeed - humanRunningSpeed)

    println("Seconds left to live: " + humanRemainingLifeTime)
  } 
}

Clone this wiki locally