Skip to content

Instantly share code, notes, and snippets.

@kechan
Last active September 27, 2017 20:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kechan/28f5ca091b8decf0b9ab2b71f0af4eee to your computer and use it in GitHub Desktop.
Save kechan/28f5ca091b8decf0b9ab2b71f0af4eee to your computer and use it in GitHub Desktop.
Some units conversion
extension Double {
var km: Double { return self } // This is stored as km, everything else will need conversion instead.
var mile: Double { return 0.6214 * self }
}
10.km
10.mile
let x = 10.0 // if user unit is miles
let dist = x/1.mile
dist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment