1_000_000 Ruby’s
Ruby ignores the underscore character within integer literals. Instead of writing
bank_account.deposit(:cash => 1000000)
you can write
bank_account.deposit(:cash => 1_000_000)
which is much easier to read.
When I’m depositing a million at my ATM however, I will a) refactor that constant out of my code and b) probably be blogging from somewhere other than my bedroom/home office =)
1 note
POSTED Saturday September 26th
-
mattonrails liked this
-
danspinosa posted this