5 ms·
Ha. TIL you can do 1_000_000.times do ... (equivalent to 1000000.times do ...). That's really nice.
by nomilk 3y ago
Ha. TIL you can do 1_000_000.times do ... (equivalent to 1000000.times do ...). That's really nice.
- jjice 3y agoA lot of languages have added support for this over the last few years. It's a nice little quality of life improvement. I use it very regularly now. I find it really handy for currency amounts in cents, so I can say `10_00` for ten dollars, in cents.
- throwiforgtnlzy 3y agoSorry, it's a been feature in a number of languages for decades. Perl has it at least as early as 5.005 in 1998. So naturally, Ruby had it since at least before 1.6 / 2002. Java added it in 2011. It didn't work with Python 2.1 from 2001, but I found it was added relatively late in PEP 515 in 2016 with Python 3.6. As a latecomer, C23 went with ' just like C++ did almost 10 years earlier with C++14.
- bdcravens 3y agoInstall the Rubocop extension in your editor and it'll bug you about it every time you have a big int (kind of annoying when you're doing one-off scripts and embed "magic numbers" like IDs from the database lol)
- Lio 3y agoListing cops with: rubocop --show-cops I can see that the NumericLiterals cop that's bothering you supports autocorrect so running: rubocop -A <filename> should fix the problem for you.