|
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 | | -# inheritance / child properties can't widen or change the parent's type |
| 128 | +# inheritance doesn't let child properties widen or change the parent's type |
129 | 129 |
|
130 | 130 | Code |
131 | 131 | new_class("foo2", foo1, properties = list(x = class_character)) |
|
149 | 149 | - <foo1>@x is <integer>. |
150 | 150 | - <foo4>@x is <ANY>. |
151 | 151 |
|
152 | | -# abstract classes / can't be instantiated |
| 152 | +# abstract classes can't be instantiated |
153 | 153 |
|
154 | 154 | Code |
155 | 155 | foo := new_class(abstract = TRUE) |
|
158 | 158 | Error in `S7::new_object()`: |
159 | 159 | ! Can't construct an object from abstract class <foo>. |
160 | 160 |
|
161 | | -# abstract classes / can't inherit from concrete class |
| 161 | +# abstract classes can't inherit from concrete class |
162 | 162 |
|
163 | 163 | Code |
164 | 164 | foo1 := new_class() |
|
167 | 167 | Error in `new_class()`: |
168 | 168 | ! Abstract classes must have abstract parents. |
169 | 169 |
|
170 | | -# abstract classes / can use inherited validator from abstract class |
| 170 | +# abstract classes can use inherited validator from abstract class |
171 | 171 |
|
172 | 172 | Code |
173 | 173 | foo2(x = 2) |
|
176 | 176 | ! <foo2> object is invalid: |
177 | 177 | - @x has bad value |
178 | 178 |
|
179 | | -# new_object() / gives useful error if called directly |
| 179 | +# new_object() gives useful error if called directly |
180 | 180 |
|
181 | 181 | Code |
182 | 182 | new_object() |
183 | 183 | Condition |
184 | 184 | Error in `new_object()`: |
185 | 185 | ! `new_object()` must be called from within a constructor. |
186 | 186 |
|
187 | | -# new_object() / errors if `_parent` doesn't inherit from the parent class (#409) |
| 187 | +# new_object() errors if `_parent` doesn't inherit from the parent class (#409) |
188 | 188 |
|
189 | 189 | Code |
190 | 190 | Foo() |
|
197 | 197 | Error in `new_object()`: |
198 | 198 | ! `_parent` must be an instance of <integer>, not <character>. |
199 | 199 |
|
200 | | -# new_object() / errors if `_parent` is supplied but class has no parent |
| 200 | +# new_object() errors if `_parent` is supplied but class has no parent |
201 | 201 |
|
202 | 202 | Code |
203 | 203 | NoParent() |
204 | 204 | Condition |
205 | 205 | Error in `new_object()`: |
206 | 206 | ! `_parent` must not be supplied when class has no parent. |
207 | 207 |
|
208 | | -# new_object() / validates object |
| 208 | +# new_object() validates object |
209 | 209 |
|
210 | 210 | Code |
211 | 211 | foo("x") |
|
220 | 220 | ! <foo> object is invalid: |
221 | 221 | - x must be positive |
222 | 222 |
|
223 | | -# new_object() / runs each parent validator exactly once |
| 223 | +# new_object() runs each parent validator exactly once |
224 | 224 |
|
225 | 225 | Code |
226 | 226 | . <- A() |
|
235 | 235 | Output |
236 | 236 | A B C |
237 | 237 |
|
238 | | -# S7 object / displays nicely |
| 238 | +# S7 object displays nicely |
239 | 239 |
|
240 | 240 | Code |
241 | 241 | foo := new_class(properties = list(x = class_double, y = class_double), |
|
253 | 253 | ..@ x: num(0) |
254 | 254 | ..@ y: num(0) |
255 | 255 |
|
256 | | -# S7 object / displays objects with data nicely |
| 256 | +# S7 object displays objects with data nicely |
257 | 257 |
|
258 | 258 | Code |
259 | 259 | text := new_class(class_character, package = NULL) |
|
266 | 266 | List of 1 |
267 | 267 | $ : <text> chr "x" |
268 | 268 |
|
269 | | -# S7 object / displays data.frame subclasses without error (#494) |
| 269 | +# S7 object displays data.frame subclasses without error (#494) |
270 | 270 |
|
271 | 271 | Code |
272 | 272 | str(mydf(data.frame(a = 1:2, b = 1:2))) |
|
276 | 276 | $ a: int 1 2 |
277 | 277 | $ b: int 1 2 |
278 | 278 |
|
279 | | -# S7 object / displays list objects nicely |
| 279 | +# S7 object displays list objects nicely |
280 | 280 |
|
281 | 281 | Code |
282 | 282 | foo1(list(x = 1, y = list(a = 21, b = 22)), x = 3, y = list(a = 41, b = 42)) |
|
0 commit comments