Last active
April 22, 2016 17:13
-
-
Save dholstius/bbdae953e6eeefbf80098b8be8ecb9cf to your computer and use it in GitHub Desktop.
Using the dot (`.`) in `fail_with`
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
# | |
# Context: | |
# | |
# https://cran.r-project.org/web/packages/ensurer/vignettes/ensurer.html says: | |
# "It is also possible to use the dot, ., directly in anonymous error handlers defined directly in the call to e.g. ensure_that." | |
# | |
# I must be misunderstanding the statement above! | |
# | |
library(ensurer) | |
ensure_only_one <- ensures_that( | |
length(.) == 1, | |
fail_with = function (err) paste0("Expecting 1 value but got ", length(.))) | |
ensure_only_one(LETTERS) # I expect this to yield "got 26" but it yields "got 2" (???) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment