-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Example accessing enum companion #14142
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
Conversation
For "future reference", so to speak.
|
7440220
to
bcaedf9
Compare
@som-snytt please would you be able to check the commit I pushed? |
@bishabosha I see you replaced royal "we"? I assumed you were required to use "royal we" as a condition of citizenship. But I am not bound to convention. |
I've noticed I have actually already used "we" in some other parts of this document (like for deprecation of enum cases) 😂 |
I will leave it to your discretion. I recently joked that so-and-so should just change their pronouns to "we". I've forgotten the context, as one ought to do when there is no implicit context. Edit: OK, now I see that the other usage of "we" is actually a deflection: No one wishes to be responsible for demoting Pluto, so it is natural to spread or diffuse the blame among the group. |
bcaedf9
to
f00102c
Compare
Is it really necessary to use that pattern matching syntax? The example would look a bit simpler if the names started with lowercase letters. I'm just thinking it might confuse novices reading the documentation, especially since enums is a simple concept that people will want to learn initially as they learn a new language. |
@oscar-broman I don't mind following up if you suggest a delta. I'm not sure what you mean, as it has been a few months. I'm not sure the text is intended for novices? I mean, I can barely follow it. |
I just meant the example could look like this instead: import Planet.*
enum Planet(mass: Double, radius: Double):
private final val (mercuryMass, mercuryRadius) = (3.303e+23, 2.4397e6)
case Mercury extends Planet(mercuryMass, mercuryRadius) // Not found
case Venus extends Planet(venusMass, venusRadius) // illegal reference
case Earth extends Planet(Planet.earthMass, Planet.earthRadius) // ok
object Planet:
private final val (venusMass, venusRadius) = (4.869e+24, 6.0518e6)
private final val (earthMass, earthRadius) = (5.976e+24, 6.37814e6)
end Planet |
I'll open a PR |
@oscar-broman Thanks for clarifying. The syntax was "pedagogical" because normally we expect "constants" to be uppercase. The idiom shown is how to achieve that. |
@bishabosha I'm agnostic as to whether the example is done the right way or the wrong way. :) |
see #14556 |
Fixes #11249