Lets say we have the member function incrementBy(int increment)
```
struct Counter {
   int count;

   void incrementBy(int increment)
   in {
      assert(increment >= 0, "increment must be zero or greater");
   }
   out {
      // want to state  assert(count == old(count) + increment);
   }
   do {
      this.count += increment;
   }
}
```

old(count) is the value of count on entry to incrementBy()
old count is Eiffel syntax.

How is this done in D?
  • Design by Contra... Brother Bill via Digitalmars-d-learn

Reply via email to