Skip to content

Commit

Permalink
add note about base::inherits() in ?S7_inherits.
Browse files Browse the repository at this point in the history
  • Loading branch information
t-kalinowski committed Nov 6, 2024
1 parent 4cbe3e1 commit 97d168e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions R/inherits.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
#' @returns
#' * `S7_inherits()` returns a single `TRUE` or `FALSE`.
#' * `check_is_S7()` returns nothing; it's called for its side-effects.
#'
#' @note Starting with \R 4.3.0, `base::inherits()` can accept an S7 class as
#' the second argument, supporting usage like `inherits(x, Foo)`.
#' @export
#' @examples
#' Foo1 <- new_class("Foo1")
Expand All @@ -21,6 +24,9 @@
#'
#' S7_inherits(Foo1(), Foo2)
#' try(check_is_S7(Foo1(), Foo2))
#'
#' if (getRversion() >= "4.3.0")
#' inherits(Foo1(), Foo1)
S7_inherits <- function(x, class = NULL) {
if (!(is.null(class) || inherits(class, "S7_class"))) {
stop("`class` must be an <S7_class> or NULL")
Expand Down
7 changes: 7 additions & 0 deletions man/S7_inherits.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 97d168e

Please sign in to comment.