Inheritance/Single: Difference between revisions
Content deleted Content added
Add Racket example |
|||
Line 1,144: | Line 1,144: | ||
setClass("Collie", representation(), prototype(), contains="Dog") |
setClass("Collie", representation(), prototype(), contains="Dog") |
||
setClass("Lab", representation(), prototype(), contains="Dog")</lang> |
setClass("Lab", representation(), prototype(), contains="Dog")</lang> |
||
=={{header|Racket}}== |
|||
<lang racket> |
|||
#lang racket |
|||
(define animal% (class object% (super-new))) |
|||
(define dog% (class animal% (super-new))) |
|||
(define cat% (class animal% (super-new))) |
|||
(define lab% (class dog% (super-new))) |
|||
(define collie% (class dog% (super-new))) |
|||
;; unit tests |
|||
(require rackunit) |
|||
(check-true (is-a? (new dog%) animal%)) |
|||
(check-false (is-a? (new collie%) cat%)) |
|||
</lang> |
|||
=={{header|REBOL}}== |
=={{header|REBOL}}== |