top | item 33843242

(no title)

cranekam | 3 years 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.)

discuss

order

quantified|3 years ago

Yes, that's the point. Credit_account_cents() would be the name that states the units.