Aman Virk
Aman Virk

Reputation: 3977

Coffeescript parameters for statements

I am having hard time finding how to do something like this in coffeescript

Javascript output

require("module")({

})

Upvotes: 0

Views: 47

Answers (1)

Guilherme Rodrigues
Guilherme Rodrigues

Reputation: 2854

This is, naturally, a matter of opinion.

I believe it pays to be explicit.

So, CoffeeScript or not, I would recommend the following:

options = {}
require('module')(options)

The CoffeeScript community style guide is rather subjective on the matter of using parentheses:

When calling functions, choose to omit or include parentheses in such a way that optimizes for readability. Keeping in mind that "readability" can be subjective, the following examples demonstrate cases where parentheses have been omitted or included in a manner that the community deems to be optimal:

baz 12

brush.ellipse x: 10, y: 20 # Braces can also be omitted or included for readability

foo(4).bar(8)

obj.value(10, 20) / obj.value(20, 10)

print inspect value

new Tag(new Value(a, b), new Arg(c))

Upvotes: 2

Related Questions