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

rewrote singleton objects tour #978

Merged
merged 2 commits into from Feb 15, 2018

Conversation

som-snytt
Copy link
Contributor

Rebased Travis's work.

@SethTisue
Copy link
Member

the addition of the .ruby-version file is accidental?

Copy link
Member

@jvican jvican left a 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.
Copy link
Member

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?

Copy link
Contributor Author

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.

@SethTisue
Copy link
Member

ping @som-snytt, shall we try to get this across the finish line?

@som-snytt
Copy link
Contributor Author

@SethTisue We shall! or maybe go for a field goal.

@SethTisue
Copy link
Member

no way. touchdown or go home.

@SethTisue SethTisue added the wip label Feb 15, 2018
@som-snytt
Copy link
Contributor Author

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.

@SethTisue SethTisue merged commit b8adaed into scala:master Feb 15, 2018
@SethTisue
Copy link
Member

I think static forwarders are adequately addressed, but no doubt someone might like to add more words later.

@jvican followup PR if you like

@SethTisue
Copy link
Member

Homer Zuckerman: There he is!
Arable: That's Som Snytt.
Avery Arable: He's terrific.
Lurvy: He's radiant.
Mrs. Zuckerman: Well, he's clean anyway. That buttermilk certainly helped.

@som-snytt
Copy link
Contributor Author

TIL snytt is norwegian for suckling pig.

@som-snytt som-snytt deleted the review/singleton-objects branch March 21, 2021 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants