Skip to content

Commit

Permalink
FAQ: small improvement in 'this type' answer (#2195)
Browse files Browse the repository at this point in the history
  • Loading branch information
SethTisue committed Oct 5, 2021
1 parent 89bb804 commit 4bfc6e1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion _overviews/FAQ/index.md
Expand Up @@ -229,7 +229,12 @@ 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?

Possible solutions include F-bounded polymorphism
First, note that 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. Only `this` itself has the
type `this.type`; other instances do not.

What does work? 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

0 comments on commit 4bfc6e1

Please sign in to comment.