Skip to content

Conversation

@MichaelChirico
Copy link
Contributor

Identified by lintr::conjunct_test_linter().

Compare:

x = TRUE
y = FALSE
# Error: x && y is not TRUE
stopifnot(x, y)
# Error: y is not TRUE

The latter gives a much friendlier failure message.

Alternatively, we could use the R>=4 feature (happy to make the change):

stopifnot("Both x and y must be TRUE" = x && y)
# Error: Both x and y must be TRUE

Note that the code works on R<4, just that it gives the earlier, less-friendly failure message.

@edzer edzer merged commit de32186 into r-spatial:main Jun 22, 2023
@MichaelChirico MichaelChirico deleted the stopifnot-and branch June 22, 2023 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants