0

In javascript I can have a route in my nodejs app that work like this:

exports.hasVote(a,b) = function(err, res) {
    res(true)
}

Problem is when I try to do the same in coffeescript (I moved to coffeescript...). So I replaced the function above with this one:

exports.hasVote(a, b) = (err, res) ->
  res true

When I run the app I get this error:

error: unexpected =

How can I accomplish this in coffeescript and have it work just like it used to in javascript?

1
  • 3
    exports.hasVote(a,b) = ... is not valid JavaScript. Commented Jan 20, 2014 at 23:49

1 Answer 1

1

You can't do that because you can't do it in JavaScript either. Coffee-script is just catching it at a higher level.

   foo() = anyThing

is not valid JavaScript (and therefore not valid CoffeeScript) because you can not assign a value to an invocation.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.