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

Method chaining lets the receiver nominate a next receiver #1673

Open
erights opened this issue Dec 25, 2017 · 2 comments
Open

Method chaining lets the receiver nominate a next receiver #1673

erights opened this issue Dec 25, 2017 · 2 comments

Comments

@erights
Copy link

erights commented Dec 25, 2017

Re https://github.com/airbnb/javascript#constructors--chaining

Code like

luke.jump().setHeight(20);

enables luke to provide something other than luke itself as the receiver of the setHeight message. When this delegation of control is intended, such method chaining is great. OTOH, if the caller assumes it is equivalent to

luke.jump();
luke.setHeight(20);

then they depend on a contract that luke might not obey. That doesn't necessarily mean the style should not be used, but the hazard needs to be explained clearly whenever this style is encouraged.

@Fatehsandhu
Copy link

@erights Hey, I am a student learning about open source development at Seneca College in Toronto. Is it possible if you can assign this to me and I would love to contribute?
Thanks a lot & Happy Holidays!

@ljharb
Copy link
Collaborator

ljharb commented Dec 26, 2017

@Fatehsandhu only repo collaborators can assign issues/PRs; only collaborators or the person who created the issue/PR can be assigned to an issue/PR. However, for this repo, anything that shows up in this search is looking for a pull request; please file one for any of them (this one included)!

Fatehsandhu added a commit to Fatehsandhu/javascript that referenced this issue Dec 26, 2017
ljharb pushed a commit to Fatehsandhu/javascript that referenced this issue Jan 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment