|
54 | 54 | #' is not possible. |
55 | 55 | #' @export |
56 | 56 | #' @examples |
57 | | -#' Foo1 <- new_class("Foo1", properties = list(x = class_integer)) |
58 | | -#' Foo2 <- new_class("Foo2", Foo1, properties = list(y = class_double)) |
| 57 | +#' Foo1 := new_class(properties = list(x = class_integer)) |
| 58 | +#' Foo2 := new_class(Foo1, properties = list(y = class_double)) |
59 | 59 | #' |
60 | 60 | #' # Upcasting: S7 provides a default implementation for coercing an object |
61 | 61 | #' # to one of its parent classes: |
|
94 | 94 | #' # Conversely, `convert()` *does* use inheritance for `from`, so a method |
95 | 95 | #' # registered on a parent class is also used for its children. This holds |
96 | 96 | #' # even when upcasting, where it overrides the default property stripping: |
97 | | -#' Bar1 <- new_class("Bar1", properties = list(label = class_character)) |
98 | | -#' Bar2 <- new_class("Bar2", Bar1) |
99 | | -#' Bar3 <- new_class("Bar3", Bar2) |
| 97 | +#' Bar1 := new_class(properties = list(label = class_character)) |
| 98 | +#' Bar2 := new_class(Bar1) |
| 99 | +#' Bar3 := new_class(Bar2) |
100 | 100 | #' method(convert, list(Bar2, Bar1)) <- function(from, to, ...) { |
101 | 101 | #' Bar1(label = "from a Bar2 or one of its children") |
102 | 102 | #' } |
|
106 | 106 | #' # This `from`-inheritance is limited to classes more specific than `to`. A |
107 | 107 | #' # method whose `from` is a *parent* of `to` would downcast, so it is skipped. |
108 | 108 | #' # For example, this method downcasts a Foo1 to a Foo2: |
109 | | -#' Foo3 <- new_class("Foo3", Foo2, properties = list(z = class_double)) |
| 109 | +#' Foo3 := new_class(Foo2, properties = list(z = class_double)) |
110 | 110 | #' method(convert, list(Foo1, Foo2)) <- function(from, to, ...) Foo2(y = -1) |
111 | 111 | #' |
112 | 112 | #' # Upcasting a Foo3 to a Foo2 ignores that inherited downcasting method, |
|
0 commit comments