Christmas is around the corner, but I couldn’t wait and I have already been trying the new Ruby release! Ruby 2.6, apart from efficiency improvements, which include the initial implementation of a just-in-time compiler, brings us many new cool features. Taking advance of the cold outside, let’s discover some of them!
It is already 2 years since Ruby 2.3 was released. While the controversial
&., which is claimed to allow writing incomprehensible code, has become really popular in blog post and conferences, we have heard very little about the
Array#dig methods. Those methods were mentioned together in the release notes, as both try to make easier dealing with
nil values. But why is then the
dig method not that “popular”? Can we after two years say something new about it? And the most important part, should we start using it, if we haven’t use it until now?
It seems I have really well behaved on 2017, because Santa Claus brought me a failing test for Christmas. I found out a piece of code, that was only wrong from 26th to 31st December. Image you want to write a Ruby method for a Rails project, where you want to get all the users of the database that have birthday today or in the next 6 days, given that the birth date is stored in the database for all users. How would you do it?