Today I Learned

A Hashrocket project

Full O' Features Ruby 2.7 has Numbered Arguments

The last TIL maybe wasn’t that useful, but you can expect to see this new language feature in a ruby file near you very soon.

> [1, 2, 3, 4].map {_1 + 1}
[2, 3, 4, 5]

Numbered Arguments! The _1 is a reference to the variable that would usually be between the pipes {|x| + 1}

So what if it’s not zero based :).

Looking for help? Each developer at Hashrocket has years of experience working with Ruby applications of all types and sizes. Contact us and find out how we can help you.