Last Updated: February 25, 2016
·
780
· chadmoran

Use _ for more readable integer literals

Though I think everyone agrees you shouldn't have arbitrary magic strings or numbers in your app, you inevitably will. Here's how you can make them a little more readable.

MY_CONST = 713014359

That's a bit hard to read, let's use some awesome Ruby syntactic sugar.

MY_CONST = 713_014_359

Much better!

>> 713_041_359 == 713041359
=> true