Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
26
Task/Inheritance-Single/REBOL/inheritance-single.rebol
Normal file
26
Task/Inheritance-Single/REBOL/inheritance-single.rebol
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
REBOL [
|
||||
Title: "Inheritance"
|
||||
URL: http://rosettacode.org/wiki/Inheritance
|
||||
]
|
||||
|
||||
; REBOL provides subclassing through its prototype mechanism:
|
||||
|
||||
Animal: make object! [
|
||||
legs: 4
|
||||
]
|
||||
|
||||
Dog: make Animal [
|
||||
says: "Woof!"
|
||||
]
|
||||
Cat: make Animal [
|
||||
says: "Meow..."
|
||||
]
|
||||
|
||||
Lab: make Dog []
|
||||
Collie: make Dog []
|
||||
|
||||
; Demonstrate inherited properties:
|
||||
|
||||
print ["Cat has" Cat/legs "legs."]
|
||||
|
||||
print ["Lab says:" Lab/says]
|
||||
Loading…
Add table
Add a link
Reference in a new issue