Skip to content
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

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

Merged
merged 2 commits into from Oct 5, 2021
Merged

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

merged 2 commits into from Oct 5, 2021

Conversation

SethTisue
Copy link
Member

@SethTisue SethTisue commented Sep 30, 2021

This comes up all the time, most recently at https://users.scala-lang.org/t/guarantees-of-this-type/7822

@SethTisue SethTisue changed the title FAQ: small improvment in 'this type' answer FAQ: small improvement in 'this type' answer Sep 30, 2021
Copy link
Contributor

@BalmungSan BalmungSan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rephrase it a bit and maybe move it below the current paragraphs as a "note".

Note: Using this.type won't work; unless your method will always return this.
People often try that to refer to the same type of the current instance, but this.type means "the singleton type of this instance", a different and too-specific meaning.

(bold to emphasize my modifications)


But overall I like it :)

@SethTisue
Copy link
Member Author

SethTisue commented Oct 5, 2021

I tweaked it a bit but I like covering this.type first. 🤷, nbd either way I guess

@SethTisue SethTisue merged commit 4bfc6e1 into scala:main Oct 5, 2021
@SethTisue SethTisue deleted the this-type branch October 5, 2021 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants