Skip to content

add Scala FAQ entry about nilary vs nullary methods #3052

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions _overviews/FAQ/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,15 @@ for multiple reasons, most notoriously
For an in-depth treatment of types vs. classes, see the blog post
["There are more types than classes"](https://typelevel.org/blog/2017/02/13/more-types-than-classes.html).

### Should I declare my parameterless method with or without parentheses?

In other words, should one write `def foo()` or just `def foo`?

Answer: by convention, the former is used to indicate that a method
has side effects.

For more details, see the Scala Style Guide, [here](https://docs.scala-lang.org/style/naming-conventions.html#parentheses).

### How can a method in a superclass return a value of the “current” type?

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