Created
May 4, 2021 07:27
-
-
Save djnavarro/6e7d05dd649b3232b52d1fad637f5e4b to your computer and use it in GitHub Desktop.
an evil paste0 function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# attach evil_shims if needed | |
if(!("evil_shims" %in% search())) { | |
attach(new.env(), name = "evil_shims", pos = 2) | |
} | |
# paste0 function appends an invisible utf8 character 10% of the time | |
# e.g., for(i in 1:100) print(paste0("a", "b") == "ab") | |
assign( | |
x = "paste0", | |
value = function(..., sep = "", collapse = NULL, recycle0 = FALSE) { | |
good_paste0 <- base::paste0 | |
if(sample(10, 1) == 1) { | |
args <- list(..., "\uFEFF", sep = sep, collapse = collapse, recycle0 = recycle0) | |
return(do.call(good_paste0, args)) | |
} else { | |
args <- list(..., sep = sep, collapse = collapse, recycle0 = recycle0) | |
return(do.call(good_paste0, args)) | |
} | |
}, | |
envir = as.environment("evil_shims") | |
) |
brb looking up how to block users on github
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Base on your idea of using
sep =
and alsoprint
-pretending to bebase::paste0
:Created on 2021-05-04 by the reprex package (v2.0.0)