Ruby 2.4.0 is coming and, since an official release is still on the oven, we can play around with new improvements in the preview1, released a couple of months ago.
If you don’t know how to install this preview, RVM allows you to install it easily (if you’re not using RVM/Rbenv/etc, well, you should):
So, once the preview1 is installed and in use, let’s play:
Integer to rule them all
In Ruby 2.3.0, integer numbers were represented by 3 different classes: Integer, Fixnum and Bignum.
In 2.4.0, they remain available, but the only concrete class is Integer. Fixnum and Bignum are now just aliases to Integer. Check it out:
Case conversion now works with Unicode
Have you already got trolled by Ruby 2.3.0 when asked to upcase the word “época” (epoch in Portuguese) or any other string with non-ascii character and got as result something like éPOCA?
Well, this is not going to happen anymore on 2.4.0.
Now, case conversion methods (like upcase, downcase, capitalize, etc) works with Unicode strings as well:
to_time now preserves timezone
In older Ruby versions, when asking for to_time in Time and DateTime objects, the timezone were lost. Ruby 2.4.0 incorporates a bug fix fixing this behaviour. Check it out:
Some performance improvements will be released as well, such like:
- Array#max and Array#min no longer creates a temporary array under certain circumstances, which improves the response time and reduce the amount of memory used by your code.
- Added Regex#match?, which just check if a given string matches the pattern, without creating a back reference object.
- Thread#report_on_exception and Thread.report_on_exception added. When set to true, a report is generated when a thread dies. Today, you can only notice this behaviour if another thread explicitly joins it.