Merck / metalite

An R package to create metadata structure for ADaM data analysis and reporting
https://merck.github.io/metalite/
GNU General Public License v3.0
15 stars 6 forks source link

Return first argument invisibly for side effect functions #114

Closed nanxstats closed 1 year ago

nanxstats commented 1 year ago

See https://style.tidyverse.org/functions.html?q=invisible#return for the rationale.

In particular, print.meta_adam().

Probably in the next release.

fb-elong commented 1 year ago

Could you show me the line of code? I did not see return() function in print.meta_adam()

nanxstats commented 1 year ago

@fb-elong Perhaps the the link I pasted was not accurately anchored because it's the latter half of the section, but here is the the exact quote:

If your function is called primarily for its side-effects (like printing, plotting, or saving to disk), it should return the first argument invisibly. This makes it possible to use the function as part of a pipe. print methods should usually do this, like this example from httr:

print.url <- function(x, ...) {
  cat("Url: ", build_url(x), "\n", sep = "")
  invisible(x)
}
elong0527 commented 1 year ago

Got it. Would you want to create a PR?