Comment

Comment by prydt

Looks like its a typo :(

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:

```D double deposit(double amount) in (amount > 0, "Deposit amount must be positive") out (result; result == balance) { balance += amount; return balance; } ```

My mistake!

https://dlang.org/spec/function.html#postconditions

parent prydt 1 month ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton