REBOL 3 Docs Guide Concepts Functions Datatypes Errors
  TOC < Back Next >   Updated: 6-Feb-2009 Edit History  

REBOL 3 Concepts: Objects: Prototype Objects

Pending Revision

This document was written for R2 and has yet to be revised for R3.

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
print maya/balance

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
maya/deposit $500

print maya/balance
print maya/first-name

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

New words are added to the object in a similar way:

maya: make lily [
    birthdate: 4-July-1977

  TOC < Back Next > - WIP Wiki Feedback Admin