You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This pattern is often easier to read than using `ggproto_parent()` and because ggproto objects are stateless it is just as safe.
However, that paragraph doesn't give a lot of guidance about when to use Class$method() and when to use ggproto_parent(Class, self)$method(). I think it would help if it was clearer that the Class$method() approach is safe when no reading or writing to/from self happens (i.e. the Class$method() formals doesn't include self), and less safe otherwise. To give an example a difference occurs:
In chapter 19.4.5 the following is said about using the
ggproto_parent()
function:ggplot2-book/internals.qmd
Line 564 in ff77ea9
However, that paragraph doesn't give a lot of guidance about when to use
Class$method()
and when to useggproto_parent(Class, self)$method()
. I think it would help if it was clearer that theClass$method()
approach is safe when no reading or writing to/fromself
happens (i.e. theClass$method()
formals doesn't includeself
), and less safe otherwise. To give an example a difference occurs:Created on 2023-07-19 with reprex v2.0.2
In the example
Coffee$describe()
would of course give the correct answer, but that is besides the point.The text was updated successfully, but these errors were encountered: