REBOL 3 Docs | Guide | Concepts | Functions | Datatypes | Errors |
TOC < Back Next > | Updated: 6-Feb-2009 Edit History |
Any object can serve as a prototype for making new objects. For instance, the lily account object previously defined can be used to make new objects with a line such as:
maya: make lily []
This makes an instance of an object. The object is a copy of the customer object and has identical values:
print lily/balance
-$890.00
print maya/balance
-$890.00
You can modify the new object while making it by providing the new values within the definition block:
maya: make lily [
first-name: "Maya"
balance: $10000
]
print maya/balance
$10000.00
maya/deposit $500
print maya/balance
$10500.00
print maya/first-name
Maya
The lily object serves as a prototype for creating the new object. Any words that are not redefined for the new object continue to have the values of the old object:
print maya/last-name
Lakeswimmer
New words are added to the object in a similar way:
maya: make lily [ email: maya@example.com birthdate: 4-July-1977 ]
TOC < Back Next > | REBOL.com - WIP Wiki | Feedback Admin |