-
Notifications
You must be signed in to change notification settings - Fork 1k
rewrote singleton objects tour #978
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
the addition of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for picking this up @som-snytt 😄!
|
||
For Java convenience, methods, including `var`s and `val`s, defined directly in a singleton object also have a static method defined in the companion class, called a *static forwarder*. Other members are accessible via the `X$.MODULE$` static field for `object X`. | ||
`static` members in Java are modeled as ordinary members of a companion object in Scala. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@som-snytt I think this is a very important concept, and there are several deletions that explain how people can encode statics in Scala 🤔 Do you think it's reasonable that we emphasize it more in the new section?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late reply. Re-reading the diff, I see that static forwarding is defined on the next line 110. I'm not sure if it's less visible in the diff, or if it really needs more words.
ping @som-snytt, shall we try to get this across the finish line? |
@SethTisue We shall! or maybe go for a field goal. |
no way. touchdown or go home. |
e3ec547
to
e028268
Compare
I did that thing where the snap is to some guy who pitches it forward to the QB. I have no idea what I'm doing, but I deleted the spurious file from the old contribution and amended my commit text. I think static forwarders are adequately addressed, but no doubt someone might like to add more words later. |
@jvican followup PR if you like |
Homer Zuckerman: There he is! |
TIL snytt is norwegian for suckling pig. |
Rebased Travis's work.