3 ms·
Units aren't clear from a callsite, though. That's the point she is making: nobody can tell if `credit_account(123)` is crediting $1.23 or $123. In a strongly-t
by cranekam 4y ago
Units aren't clear from a callsite, though. That's the point she is making: nobody can tell if `credit_account(123)` is crediting $1.23 or $123. In a strongly-typed world if `credit_account` took cents and the called passed dollars they'd have to explicitly cast it along the lines of `credit_account(to_cents(123))`.
(Also worth noting: never use a float to represent dollars and cents (or whatever currency) amounts because floating point precision will get you.)
- quantified 4y agoYes, that's the point. Credit_account_cents() would be the name that states the units.