Skip to content

Commit a3c5206

Browse files
committed
add Scala FAQ entry about nilary vs nullary methods
1 parent e42fca5 commit a3c5206

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Diff for: _overviews/FAQ/index.md

+9
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,15 @@ for multiple reasons, most notoriously
273273
For an in-depth treatment of types vs. classes, see the blog post
274274
["There are more types than classes"](https://typelevel.org/blog/2017/02/13/more-types-than-classes.html).
275275

276+
### Should I declare my parameterless method with or without parentheses?
277+
278+
In other words, should one write `def foo()` or just `def foo`?
279+
280+
Answer: by convention, the former is used to indicate that a method
281+
has side effects.
282+
283+
For more details, see the Scala Style Guide, [here](https://docs.scala-lang.org/style/naming-conventions.html#parentheses).
284+
276285
### How can a method in a superclass return a value of the “current” type?
277286

278287
First, note that using `this.type` won't work. People often try that,

0 commit comments

Comments
 (0)