Reputation: 2938
Say I've got the code:
cat = {
feed: (food) ->
alert "cat ate #{food}"
}
pets = {
"maximus": cat
}
getPet = (name) ->
pets[name]
How can I invoke the "feed" method of returned by "getPet" cat object? This is not a valid code:
getPet "maximus" feed "Fish"
In plain javascript it would look like this:
getPet("maximus").feed("Fish");
Upvotes: 2
Views: 432
Reputation: 4771
You can't do chaining without the parentheses on the left-most parts of the chain.
getPet('maximus').feed 'fish'
Upvotes: 4