When you use a splat, the splat puts the splatted arguments into an array. For example:
f = (x...) -> console.log(x instanceof Array)
f(6)
will give you a true
in the console. The fine manual isn't so fine in this case, it doesn't exactly spell it out, it assumes that you understand how JavaScript's arguments
object works and leaves out the explicit splat puts your arguments into an array part.
So you end up passing an array to check
and an array compared with a string using CoffeeScript's ==
(or JavaScript's ===
) will never be true.
If you want emit
to check the first argument, then you need to say so:
emit = (args...) -> check(args[0])