Skip to content

Commit

Permalink
Added a function for the ternary operator.
Browse files Browse the repository at this point in the history
(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
matthewp committed Oct 17, 2012
1 parent dfe0c27 commit 6403b4e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/macros.sibilant
Expand Up @@ -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.