Object Contracts Sample Clauses
Object Contracts. An object contract is a simple key/contract map. It is defined by a mapping from key values (which are either property names, array indices, or symbols) to contracts. Like a function contract, an object contract is delayed. All contracts in the mapping are dormant until the associated property is addressed by a property read or property write operation. When reading a property, the contract gets asserted to the accessed value before it is given to the context, whereas writing a property asserts the contract to the new value. The following example demonstrates the construction of an object contract that indicates that the length property of an object has to be a value of type "number". The constructor Contract.Object takes an enumerable JavaScript object (either an array or a normal object) that maps key values to contracts.
1 Contract.Object({length:typeNumber});
