logoalt Hacker News

lgasyesterday at 5:58 PM2 repliesview on HN

I've never used D, but it appears to be valid syntax. https://dlang.org/spec/function.html#postconditions


Replies

diathyesterday at 6:02 PM

I'm not asking about the syntax, I'm asking about the logic where a value can be equal to itself plus another value when the pre-condition is that it must be > 0.

prydtyesterday at 6:02 PM

The syntax is correct but I made a logical error since balance is being compared to itself (as opposed to the new balance at the end).