|
1 | | -# S7 classes / print nicely |
| 1 | +# S7 classes print nicely |
2 | 2 |
|
3 | 3 | Code |
4 | 4 | foo2 |
|
41 | 41 | List of 1 |
42 | 42 | $ : <foo2/foo1/S7_object> constructor |
43 | 43 |
|
44 | | -# S7 classes / prints @package and @abstract details |
| 44 | +# S7 classes print @package and @abstract details |
45 | 45 |
|
46 | 46 | Code |
47 | 47 | foo |
|
52 | 52 | @ validator : <NULL> |
53 | 53 | @ properties : |
54 | 54 |
|
55 | | -# S7 classes / shows property defaults and read-only annotations |
| 55 | +# S7 classes show property defaults and read-only annotations |
56 | 56 |
|
57 | 57 | Code |
58 | 58 | Person |
|
69 | 69 | $ default_expr: S3<Date> = Sys.Date() |
70 | 70 | $ read_only: <ANY> [read-only] |
71 | 71 |
|
72 | | -# S7 classes / checks inputs |
| 72 | +# S7 classes check inputs |
73 | 73 |
|
74 | 74 | Code |
75 | 75 | new_class(1) |
|
107 | 107 | Error in `new_class()`: |
108 | 108 | ! `validator` must be function(self), not function(). |
109 | 109 |
|
110 | | -# S7 classes / can't inherit from S4 or class unions |
| 110 | +# S7 classes can't inherit from S4 or class unions |
111 | 111 |
|
112 | 112 | Code |
113 | 113 | new_class("test", parent = parentS4) |
|
125 | 125 | * An S4 class object |
126 | 126 | * A base class |
127 | 127 |
|
128 | | -# abstract classes / can't be instantiated |
| 128 | +# abstract classes can't be instantiated |
129 | 129 |
|
130 | 130 | Code |
131 | 131 | foo := new_class(abstract = TRUE) |
|
134 | 134 | Error in `S7::new_object()`: |
135 | 135 | ! Can't construct an object from abstract class <foo>. |
136 | 136 |
|
137 | | -# abstract classes / can't inherit from concrete class |
| 137 | +# abstract classes can't inherit from concrete class |
138 | 138 |
|
139 | 139 | Code |
140 | 140 | foo1 := new_class() |
|
143 | 143 | Error in `new_class()`: |
144 | 144 | ! Abstract classes must have abstract parents. |
145 | 145 |
|
146 | | -# abstract classes / can use inherited validator from abstract class |
| 146 | +# abstract classes can use inherited validator from abstract class |
147 | 147 |
|
148 | 148 | Code |
149 | 149 | foo2(x = 2) |
|
152 | 152 | ! <foo2> object is invalid: |
153 | 153 | - @x has bad value |
154 | 154 |
|
155 | | -# new_object() / gives useful error if called directly |
| 155 | +# new_object() gives useful error if called directly |
156 | 156 |
|
157 | 157 | Code |
158 | 158 | new_object() |
159 | 159 | Condition |
160 | 160 | Error in `new_object()`: |
161 | 161 | ! `new_object()` must be called from within a constructor. |
162 | 162 |
|
163 | | -# new_object() / errors if `_parent` doesn't inherit from the parent class (#409) |
| 163 | +# new_object() errors if `_parent` doesn't inherit from the parent class (#409) |
164 | 164 |
|
165 | 165 | Code |
166 | 166 | Foo() |
|
173 | 173 | Error in `new_object()`: |
174 | 174 | ! `_parent` must be an instance of <integer>, not <character>. |
175 | 175 |
|
176 | | -# new_object() / errors if `_parent` is supplied but class has no parent |
| 176 | +# new_object() errors if `_parent` is supplied but class has no parent |
177 | 177 |
|
178 | 178 | Code |
179 | 179 | NoParent() |
180 | 180 | Condition |
181 | 181 | Error in `new_object()`: |
182 | 182 | ! `_parent` must not be supplied when class has no parent. |
183 | 183 |
|
184 | | -# new_object() / validates object |
| 184 | +# new_object() validates object |
185 | 185 |
|
186 | 186 | Code |
187 | 187 | foo("x") |
|
196 | 196 | ! <foo> object is invalid: |
197 | 197 | - x must be positive |
198 | 198 |
|
199 | | -# new_object() / runs each parent validator exactly once |
| 199 | +# new_object() runs each parent validator exactly once |
200 | 200 |
|
201 | 201 | Code |
202 | 202 | . <- A() |
|
211 | 211 | Output |
212 | 212 | A B C |
213 | 213 |
|
214 | | -# S7 object / displays nicely |
| 214 | +# S7 object displays nicely |
215 | 215 |
|
216 | 216 | Code |
217 | 217 | foo := new_class(properties = list(x = class_double, y = class_double), |
|
229 | 229 | ..@ x: num(0) |
230 | 230 | ..@ y: num(0) |
231 | 231 |
|
232 | | -# S7 object / displays objects with data nicely |
| 232 | +# S7 object displays objects with data nicely |
233 | 233 |
|
234 | 234 | Code |
235 | 235 | text := new_class(class_character, package = NULL) |
|
242 | 242 | List of 1 |
243 | 243 | $ : <text> chr "x" |
244 | 244 |
|
245 | | -# S7 object / displays data.frame subclasses without error (#494) |
| 245 | +# S7 object displays data.frame subclasses without error (#494) |
246 | 246 |
|
247 | 247 | Code |
248 | 248 | str(mydf(data.frame(a = 1:2, b = 1:2))) |
|
252 | 252 | $ a: int 1 2 |
253 | 253 | $ b: int 1 2 |
254 | 254 |
|
255 | | -# S7 object / displays list objects nicely |
| 255 | +# S7 object displays list objects nicely |
256 | 256 |
|
257 | 257 | Code |
258 | 258 | foo1(list(x = 1, y = list(a = 21, b = 22)), x = 3, y = list(a = 41, b = 42)) |
|
0 commit comments