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

Support method chaining #151

Closed
jayqi opened this issue Dec 19, 2018 · 0 comments · Fixed by #181
Closed

Support method chaining #151

jayqi opened this issue Dec 19, 2018 · 0 comments · Fixed by #181

Comments

@jayqi
Copy link
Collaborator

jayqi commented Dec 19, 2018

It's common practice in object-oriented programming to support method chaining.

Unfortunately, we have several methods that should work this way (under typical OOP implementations) but return invisible(NULL) instead of invisible(self). One example of this is $set_package, which means you can't do something like this:

library(pkgnet)
FunctionReporter$new()$set_package('baseballstats')$pkg_graph
#> INFO [2018-12-18 22:17:36] Checking installed packages...
#> INFO [2018-12-18 22:17:36] Found 'baseballstats' in installed packages.
#> INFO [2018-12-18 22:17:36] Resetting cached network information...
#> NULL

We should go through and change all public methods that don't return something specific to return invisible(self).

Created on 2018-12-18 by the reprex package (v0.2.1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants