1 comments

  • diath13 minutes ago
    <p><pre><code> out (; balance == balance + amount) &#x2F;&#x2F; checked after method returns </code></pre> How exactly does it work? Is this a typo?
    • prydt1 minute ago
      Looks like its a typo :(<p>The correct way to go about this would be to return the new balance and capture the return value in the first part of the out postcondition like:<p>```D double deposit(double amount) in (amount &gt; 0, &quot;Deposit amount must be positive&quot;) out (result; result == balance) { balance += amount; return balance; } ```<p>My mistake!<p><a href="https:&#x2F;&#x2F;dlang.org&#x2F;spec&#x2F;function.html#postconditions" rel="nofollow">https:&#x2F;&#x2F;dlang.org&#x2F;spec&#x2F;function.html#postconditions</a>
    • lgas3 minutes ago
      I&#x27;ve never used D, but it appears to be valid syntax. <a href="https:&#x2F;&#x2F;dlang.org&#x2F;spec&#x2F;function.html#postconditions" rel="nofollow">https:&#x2F;&#x2F;dlang.org&#x2F;spec&#x2F;function.html#postconditions</a>