TIL: `x ? y` in CoffeeScript is a shorthand for `if x? then x else y`.

Akinori MUSHA 10 years ago
parent
commit
1784eeb38a
1 changed files with 1 additions and 1 deletions
  1. 1 1
      app/assets/javascripts/map_marker.js.coffee

+ 1 - 1
app/assets/javascripts/map_marker.js.coffee

@@ -19,7 +19,7 @@ window.map_marker = (map, options = {}) ->
19 19
 
20 20
   if options.course
21 21
     p1 = new LatLon(pos.lat(), pos.lng())
22
-    speed = if options.speed? then options.speed else 1
22
+    speed = options.speed ? 1
23 23
     p2 = p1.destinationPoint(options.course, Math.max(0.2, speed) * 0.1)
24 24
 
25 25
     lineCoordinates = [