Permalink
Browse files

Added a function for the ternary operator.

(ternary cond if-true if-false) operates a lot like (if), only that it
transforms the result into a ternary expression in JavaScript.
  • Loading branch information...
1 parent dfe0c27 commit 6403b4ed1bfb6aa66b38c4a9c4b386c8ac447ac7 @matthewp matthewp committed Oct 17, 2012
Showing with 3 additions and 0 deletions.
  1. +3 −0 include/macros.sibilant
View
@@ -359,3 +359,6 @@
(concat (translate k) " = " (translate v))))
(if (undefined? body) ");"
(concat ") {" (indent (translate body)) "}"))))
+
+(defmacro ternary (cond if-true if-false)
+ (concat (translate cond) " ? " (translate if-true) " : " (translate if-false)))

0 comments on commit 6403b4e

Please sign in to comment.