D Language Contracts Function contracts


For example if an method is invoked the state of the object may not allow that a method is called with specific parameters or not at all.

class OlderThanEighteen {
    uint age;

    final void driveCar()
    in {
         assert(age >= 18); // variable must be in range
    body {
         // step on the gas