RUN
CLOSE
# Your Macros # Too famous `swap` macro macro.swap = (x, y)-> $tmp = x x = y y = $tmp # using splats to get whole body macro.func = (func_name, func...)-> func_name = -> "use strict" func # some literal macros literal /assign (.*) to (.*)/, (first, second)-> second = first literal /(.*) is actually (.*)/, (first, second)-> first = second console.log "Changed using literal" literal /(.*) greater than (.*)/, (f, s)-> f > s
# Your Source # create strict function using `func` macro. func hello, -> name = "john" surname = "doe" # use swap macro swap name, surname console.log "Hello #{name}, #{surname}" # use a literal macro "world is actually hello" world() # => Hello doe, john # use a literal macro inline if "10 greater than 5" console.log "10 is great! Long live 10!"