I'd like to put arguments on different lines, but I get parse errors on all the variations I try, including adding commas, allwin-style parens, and different indentations.
constructor: (
@a
@b
@c
) ->
Yes, it matters. The arguments must be given in the order the function expects them. C passes arguments by value. It has no way of associating a value with an argument other than by position.
Except for functions with variable-length argument lists, the number of arguments in a function call must be the same as the number of parameters in the function definition. This number can be zero. The maximum number of arguments (and corresponding parameters) is 253 for a single function.
Information can be passed into functions as arguments. Arguments are specified after the function name, inside the parentheses. You can add as many arguments as you want, just separate them with a comma. The following example has a function with one argument (fname).
Try:
constructor:\
( @a
, @b
, @c
) ->
Both trailing \
and leading ,
suppress newlines in CoffeeScript.
It appears you are out of luck. If you look at the grammar rules for the function definition, you will see that the rule is defined as:
'PARAM_START ParamList PARAM_END FuncGlyph Block'
The rule for Block
allows for TERMINATOR
tokens (which are semi-colon or carriage return) but the ParamList
rule (the one you are interested in adding a new line in) does not allow for it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With