Ruby 3.0 adds

After the last four or five years of the promises of a new major version of Ruby (Ruby 3), it looks like this new version is set to release on December 25, 2020. This article will look at one new feature.


There are three main goals for this future release.

New Hash method

Ruby 3 will add a new method for a hash #except, which returns a new hash.

Assuming the hash: {food: "Burger", beverage: "Coffee", fries: "large"}, in Rails 6, we can exclude an item like so:

{food: "Burger", beverage: "Coffee", fries: "large"}.except(:fries)

and it returns the hash: {food: "Burger", beverage: "Coffee"}

Currently in the latest version of Ruby, you can use slice to build the new hash you want, a different approach to yield the same results:

{food: "Burger", beverage: "Coffee", fries: "large"}.slice(:food, :beverage)

and it returns the hash: {food: "Burger", beverage: "Coffee"}

*Ruby 3

Now with Ruby 3, you can use the new #except method: {food: "Burger", beverage: "Coffee", fries: "large"}.except(:fries)

Also, you can exclude mulitple items: {food: "Burger", beverage: "Coffee", fries: "large"}.except(:fries, :food)

Nice edition to the Ruby language with more to come. Stay tuned for more.


This has been fun. Leave a comment or send me a DM on Twitter.

Shameless Plug: If you work at a great company, and you are in the market for a Software Developer with a varied skill set and life experiences, send me a message on Twitter and check out my LinkedIn.