Skip to content

Commit 4bfc6e1

Browse files
authored
FAQ: small improvement in 'this type' answer (#2195)
1 parent 89bb804 commit 4bfc6e1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

_overviews/FAQ/index.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,12 @@ For an in-depth treatment of types vs. classes, see the blog post
229229

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

232-
Possible solutions include F-bounded polymorphism
232+
First, note that using `this.type` won't work. People often try that,
233+
but `this.type` means "the singleton type of this instance", a
234+
different and too-specific meaning. Only `this` itself has the
235+
type `this.type`; other instances do not.
236+
237+
What does work? Possible solutions include F-bounded polymorphism
233238
_(familiar to Java programmers)_, type members,
234239
and the [typeclass pattern](http://tpolecat.github.io/2013/10/12/typeclass.html).
235240

0 commit comments

Comments
 (0)