Require (keyword)

From The Oxygene Language Wiki

Jump to:navigation, search

This is a Language topic
Feel free to add your notes to this topic below.



The "require" pre condition

Pre conditions are a part of Class Contracts and are used to describe conditions that are required to be true when a method is called. They can be used to check for the validity of input parameters or for the state of the object required by the method.

The require section consists of a list of Boolean statements, separated by semicolons.

Example

method MyObject.DivideBy(aValue: Integer);
require
  aValue <> 0;
begin
  MyValue := MyValue/aValue;
end;

If the require condition is not met, an assertion failure occurs. See the ensure topic for a failure example.


See Also


Oxygene-48.png

Area: Oxygene Language
Compiler version: Oxygene 5

Language GlossaryKeywordsTypesFAQHow To

Navigation
Areas
More
Toolbox