Skip to content

[R-package] fixed uses of class()#5426

Merged
pommedeterresautee merged 1 commit intodmlc:masterfrom
jameslamb:r/class
Mar 20, 2020
Merged

[R-package] fixed uses of class()#5426
pommedeterresautee merged 1 commit intodmlc:masterfrom
jameslamb:r/class

Conversation

@jameslamb
Copy link
Contributor

In this PR, I'd like to propose a minor change in the R package. I found two passes where typeof(x) == 'list or typeof(x) != 'list' is being used to check that something is a list.

This check isn't totally safe, since data.table or data.frame objects will pass this check.

typeof(data.frame())

[1] "list"

typeof(data.table::data.table())

[1] "list"

In this PR, I propose changing to a stricter check, identical(class(x)) == 'list'.

Thanks for your time and consideration!

@pommedeterresautee pommedeterresautee merged commit 4b7e2b7 into dmlc:master Mar 20, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Jun 24, 2020
@jameslamb jameslamb deleted the r/class branch June 1, 2021 04:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants