tests/testthat/good_print/R/print.R

print.simple <- function(x, ...) {
  cat("simple object\n")
  invisible(x)
}

print.nested <- function(x, ...) {
  if (length(x) > 0) {
    cat(format(x), sep = "\n")
    invisible(x)
  } else {
    cat("empty\n")
    invisible(x)
  }
}

print.assigned_with_equals = function(x, ...) {
  cat("equals object\n")
  invisible(x)
}

print.with_helper <- function(x, ...) {
  fmt <- function(val) paste0("[", val, "]")
  cat(fmt(x), "\n")
  invisible(x)
}

Try the goodpractice package in your browser

Any scripts or data that you put into this service are public.

goodpractice documentation built on June 5, 2026, 5:06 p.m.