langs a-z
This commit is contained in:
parent
db842d013d
commit
d066446780
11389 changed files with 98361 additions and 1020 deletions
28
Task/Inheritance-Single/REBOL/inheritance-single.rebol
Normal file
28
Task/Inheritance-Single/REBOL/inheritance-single.rebol
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
REBOL [
|
||||
Title: "Inheritance"
|
||||
Author: oofoe
|
||||
Date: 2009-12-08
|
||||
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