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

Conversation

@richierocks
Copy link
Contributor

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.

@wch
Copy link
Member

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.

R/is.R Outdated
#' 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

This comment has been minimized.

Copy link
@wch

wch Sep 19, 2016

Member

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

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

This comment has been minimized.

Copy link
@wch

wch Sep 19, 2016

Member

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

R/is.R Outdated

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

This comment has been minimized.

Copy link
@wch

wch Sep 19, 2016

Member

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.

R/is.R Outdated
#' is.R6Class(object)
#' is.R6(object)
#' @export
#' @rdname is.r6

This comment has been minimized.

Copy link
@wch

wch Sep 20, 2016

Member

I think you can remove this @rdname,

R/is.R Outdated
inherits(x, "R6")
}

#' @rdname is.r6

This comment has been minimized.

Copy link
@wch

wch Sep 20, 2016

Member

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

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.