Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added is* fns #95

Merged
merged 3 commits into from Sep 21, 2016
Merged

added is* fns #95

merged 3 commits into from Sep 21, 2016

Conversation

richierocks
Copy link
Contributor

@richierocks richierocks commented Sep 18, 2016

I added is.r6gen to check for R6 class generators, is.r6obj to check for R6 objects, and is.r6 to check for either of those types.

Copy link
Member

@wch wch left a comment

I like the general idea, but I'd prefer it to work like this:

is.R6 <- function(x) inherits(x, "R6")

is.R6Class <- function(x) inherits(x, "R6ClassGenerator")

(In retrospect, I should have given the generator object the class "R6Class" instead of "R6ClassGenerator", but it's probably too late to change that now.)

I don't think it's necessary to have one function that tests for both.

#' Checks for R6 class generators and R6 objects.
#' @param x Any variable.
#' @return A logical value.
#' \code{is.r6} returns \code{TRUE} when the input is an R6 class generator or
Copy link
Member

@wch wch Sep 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would look better with an \itemize list.

#' \code{is.r6obj} returns \code{TRUE} when the input is an R6 object and
#' \code{FALSE} otherwise.
#' @examples
#' class_generator <- R6::R6Class()
Copy link
Member

@wch wch Sep 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd leave out the R6:: for consistency with other examples.


#' @rdname is.r6
#' @export
is.r6obj <- function(x)
Copy link
Member

@wch wch Sep 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer the opening brace to be on the same line as the function(), or for these very simple one-liners, no brace at all.

#' is.R6Class(object)
#' is.R6(object)
#' @export
#' @rdname is.r6
Copy link
Member

@wch wch Sep 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can remove this @rdname,

inherits(x, "R6")
}

#' @rdname is.r6
Copy link
Member

@wch wch Sep 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be @rdname is.R6.

wch
wch approved these changes Sep 21, 2016
@wch wch merged commit 75c17f5 into r-lib:master Sep 21, 2016
2 checks passed
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.

None yet

2 participants