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

Document Need to Define Classes in Order #325

Open
jonthegeek opened this issue Aug 25, 2023 · 0 comments
Open

Document Need to Define Classes in Order #325

jonthegeek opened this issue Aug 25, 2023 · 0 comments

Comments

@jonthegeek
Copy link
Contributor

This is somewhat discussed in #250 (in particular here), but before fully solving that issue it feels like it would be helpful to point out that a class needs to be defined earlier in a script or package if you want to use it as a property in another class. This is particularly confusing in a package context, so perhaps add it to the packages vignette?

# Causes the package to fail to build.
s7_parent <- S7::new_class(
  "s7_parent",
  package = "newS7fanciness",
  properties = list(name = s7_child)
)
#> Error in eval(expr, envir, enclos): object 's7_child' not found

s7_child <- S7::new_class(
  "s7_child",
  package = "newS7fanciness",
  properties = list(x = S7::class_character)
)

Created on 2023-08-25 with reprex v2.0.2

# Works
s7_child <- S7::new_class(
  "s7_child",
  package = "newS7fanciness",
  properties = list(x = S7::class_character)
)

s7_parent <- S7::new_class(
  "s7_parent",
  package = "newS7fanciness",
  properties = list(name = s7_child)
)

Created on 2023-08-25 with reprex v2.0.2

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

No branches or pull requests

1 participant