Go to content
The Codest
  • About Us
  • Services
  • Our Team
  • Case studies
    • Blog
    • Meetups
    • Webinars
    • Resources
Careers Get in touch
  • About Us
  • Services
  • Our Team
  • Case studies
    • Blog
    • Meetups
    • Webinars
    • Resources
Careers Get in touch
2019-04-08
Software Development

A quick dive into Ruby 2.6. What is new?

Patrycja Slabosz

A quick dive into Ruby 2.6. What is new? - Image

Released quite recently, Ruby 2.6 brings a bunch of conveniences that may be worth taking a glimpse of.  What is new? Let’s give it a shot!

1. Endless ranges

Ruby 2.6 introduces endless ranges, which makes expressions like:

possible.

2. Array

Ruby 2.6 provides new methods and aliases for Array class. I.e:

  • Array#difference - works like  “I”‚ operator, but accepts multiple arguments.
  • Array#union -  works like “&” operator, but accepts multiple arguments.
  • Array#filter - new alias for Array#select.

Code 2

3. Hash

Hash#merge and Hash#merge! accept now multiple arguments. No more code like: hash1.merge(hash2).merge(hash3)!

Code 3

4. Kernel#then

Ruby 2.6 provides method Kernel#then, which is an alias to Kernel#yield_self, allowing us to chain operations into pipelines and making the code more readable.

Code4

5. New way to create a hash out of the array

Ruby 2.6 provides Enumerable#to_h method which accepts a block and maps keys to values!

Let’s remind shortly how we had to deal with creating a hash out of array before Ruby 2.6:

Code5

From now on, it’s possible to do this simply like this:

Code6

How cool is that!

6.  Proc#compose - a little bit of Ruby magic or just an unreadable mess?

Since Ruby 2.6 Proc#>> and Proc#<< methods were added, allowing us to combine two functions. Let’s look at this:

Code7

With the #>> operation, the number gets into exponentiation function first and then minus_two is performed on the result of the first function call. Although it seems useful and gives us a bit of magic, that we all love Ruby for, some say that code written like this becomes just an unreadable mess.

These are, in my opinion, the most interesting conveniences which Ruby 2.6 provides us with. I highly recommend taking a glimpse of official changelog too.

Read also:

- Writing documentation has become easy thanks to VuePress

- Security in Javascript packages

- Vue.js basics tutorial. How to start with this framework?

Related articles

Software Development

3 Useful HTML Tags You Might Not Know Even Existed

Nowadays, accessibility (A11y) is crucial on all stages of building custom software products. Starting from the UX/UI design part, it trespasses into advanced levels of building features in code. It provides tons of benefits for...

Jacek Ludzik
Software Development

5 examples of Ruby’s best usage

Have you ever wondered what we can do with Ruby? Well, the sky is probably the limit, but we are happy to talk about some more or less known cases where we can use this powerful language. Let me give you some examples.

Pawel Muszynski
Software Development

Maintaining a Project in PHP: 5 Mistakes to Avoid

More than one article has been written about the mistakes made during the process of running a project, but rarely does one look at the project requirements and manage the risks given the technology chosen.

Sebastian Luczak
Software Development

5 reasons why you will find qualified Ruby developers in Poland

Real Ruby professionals are rare birds on the market. Ruby is not the most popular technology, so companies often struggle with the problem of finding developers who have both high-level skills and deep experience; oh, and by the...

Jakub
Software Development

9 Mistakes to Avoid While Programming in Java

What mistakes should be avoided while programming in Java? In the following piece we answers this question.

Rafal Sawicki
Software Development

A Quick Primer on Refactoring for Beginners

Perhaps I am writing about something obvious to many, but maybe not to everyone. Refactoring is, I think, a complicated topic because it involves changing the code without affecting its operation.

Marta Świątkowska

Subscribe to our knowledge base and stay up to date on the expertise from industry.

About us

We are an agile software development company dedicated to empowering our clients' digital transformation projects and ensuring successful IT project delivery.

    United Kingdom - Headquarters

  • Office 303B, 182-184 High Street North E6 2JA London, England

    Poland - Local Tech Hubs

  • Business Link High5ive, Pawia 9, 31-154 Kraków, Poland
  • Brain Embassy, Konstruktorska 11, 02-673 Warsaw, Poland
  • Aleja Grunwaldzka 472B, 80-309 Gdańsk, Poland

    The Codest

  • Home
  • About us
  • Services
  • Case studies
  • Know how
  • Careers

    Services

  • PHP development
  • Java development
  • Python development
  • Ruby on Rails development
  • React Developers
  • Vue Developers
  • TypeScript Developers
  • DevOps
  • QA Engineers

    Resources

  • What are top CTOs and CIOs Challenges? [2022 updated]
  • Facts and Myths about Cooperating with External Software Development Partner
  • From the USA to Europe: Why do American startups decide to relocate to Europe
  • Privacy policy
  • Website terms of use

Copyright © 2022 by The Codest. All rights reserved.

We use cookies on the site for marketing, analytical and statistical purposes. By continuing to use, without changing your privacy settings, our site, you consent to the storage of cookies in your browser. You can always change the cookie settings in your browser. You can find more information in our Privacy Policy.