Skip to content

Commit d3ccb1f

Browse files
committed
optimize parentheses in method calls for readability
1 parent 7853444 commit d3ccb1f

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,20 @@ In cases where method calls are being chained and the code does not fit on a sin
243243
.reduce((x, y) -> x + y)
244244
```
245245

246-
When calling functions, omit the parentheses on the final method call in a chain. For example:
246+
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:
247247

248248
```coffeescript
249249
baz 12
250250

251-
foo(4).bar 8
251+
brush.ellipse x: 10, y: 20 # Braces can also be omitted or included for readability
252+
253+
foo(4).bar(8)
254+
255+
obj.value(10, 20) / obj.value(20, 10)
256+
257+
print inspect value
258+
259+
new Tag(new Value(a, b), new Arg(c))
252260
```
253261

254262
You will sometimes see parentheses used to group functions (instead of being used to group function parameters). Examples of using this style (hereafter referred to as the "function grouping style"):

0 commit comments

Comments
 (0)