Skip to content

FAQ: small improvement in 'this type' answer #2195

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 2 commits into from
Oct 5, 2021
Merged
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions _overviews/FAQ/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ For an in-depth treatment of types vs. classes, see the blog post

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

Using `this.type` won't work. People often try that, but `this.type` means
"the singleton type of this instance", a different and too-specific meaning.

Possible solutions include F-bounded polymorphism
_(familiar to Java programmers)_, type members,
and the [typeclass pattern](http://tpolecat.github.io/2013/10/12/typeclass.html).
Expand Down