Skip to content

Commit

Permalink
Tighten chatty() example (#1642)
Browse files Browse the repository at this point in the history
I may be missing a deeper point here, but it seems simpler for `chatty()` to use `message()` instead of `cat()` and call it before the processing begins?
  • Loading branch information
dkahle committed Mar 19, 2023
1 parent 320ec82 commit 14bdb11
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions Function-operators.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ chatty <- function(f) {
force(f)
function(x, ...) {
res <- f(x, ...)
cat("Processing ", x, "\n", sep = "")
res
message("Processing ", x)
f(x, ...)
}
}
f <- function(x) x ^ 2
Expand Down

0 comments on commit 14bdb11

Please sign in to comment.