1. 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 =)

     

    tags:  ruby  knowledge 

    Comments
  2. blog comments powered by Disqus