Skip to content

Instantly share code, notes, and snippets.

@seraphr
Created November 13, 2017 07:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seraphr/cdee852ce90efab7fd6c40b81efbb5b6 to your computer and use it in GitHub Desktop.
Save seraphr/cdee852ce90efab7fd6c40b81efbb5b6 to your computer and use it in GitHub Desktop.
scala this.type
scala> class Hoge {
| def m1: this.type = this // OK
| def m2: this.type = new Hoge // NG
| }
<console>:9: error: type mismatch;
found : Hoge
required: Hoge.this.type
def m2: this.type = new Hoge // NG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment