1

Computed properties on ember views have the form

myComputedProperty: function() {
    return doSomething();
}.property()

However, when I write this in coffescript as

myComputedProperty: ->
    doSomething()
.property()

I get an error like "Parse error on line 5: Unexpected '.'". Am I doing something wrong, or is this a quirk of the interpreter I'm using (Mindscape VS plugin)?

1

2 Answers 2

1

The grammar of the language doesn't support this. You have to add parenthesis around the function:

myComputedProperty: (->
    doSomething()
).property()
Sign up to request clarification or add additional context in comments.

Comments

1

You can add () around the function, or you can make the syntax more coffeescript friendly:

prop = (fn) -> fn.property()

myComputedProperty: prop ->
    doSomething()

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.