Polymorphic copy: Difference between revisions

m
Racket →‎Using classes: use inherit-field
(Add Racket Task)
m (Racket →‎Using classes: use inherit-field)
Line 1,340:
(class point%
(super-new)
(inherit-field x y)
(init-field color)
(define/override (clone) (new this% [x (get-field x this)] [y (get-field y this)] [color color]))
(define/override (to-list) (list this% (get-field x this) (get-field y this) color))))</lang>
</lang>
{{out}}
<pre>(#<class:point%> 0 0)
Anonymous user