it
I recall watching one of Jonathan Blow's presentations on his upcoming programming language Jai a couple of years ago and noticing that whenever he iterated over a collection, he referenced the current element using a special identifier called it.
At the time, Ruby allowed referencing block arguments via _1, _2, etc. But I never felt that it fit with the aesthetics of Ruby, being weirdly computery and far removed from human language. But it just clicked for me and I immediately wished Ruby had something similar.
So I got quite excited when a proposal to add it to Ruby landed in the Ruby issue tracker in 2022, and after a year of deliberation, Matz agreed to roll out the feature, first by warning about existing usage of it in Ruby 3.3, and then finally shipping it in Ruby 3.4. So here we are!
[1, 2, 3].map { it * 2 }
# => [2, 4, 6]
To be honest I haven't made a habit of using this in production code yet, since it tends to break conventions used in existing codebases. But I do find myself using it in irb all the time, since it makes for the least amount of typing required to get a piece of code running, and I'm loving it!
History
When Ruby added numbered block parameters like _1 and _2 in Ruby 2.7, there was already some discussion about adding an it identifier for the first block parameter, but it was ultimately decided against at the time.
The main reason was a concern that it would conflict with existing Ruby code and make it a backwards compatibility hazard.
However, with time, a clear strategy for handling introduction of it in a way which minimizes breakage emerged, which led to the proposal being accepted in 2023, and finally merged into Ruby in 2024. I believe one of the key ideas was that it should only work in blocks that do not explicitly declare their parameters, which limits the scope of potential conflicts.
[1, 2, 3].map { |number| it * 2 }
# => SyntaxError: 'it' is not allowed when an ordinary parameter is defined
Very few other languages have it. Kotlin and Groovy are the only production-ready languages I'm aware of that have it. Finally, there's Jai, but that language, as of today, is still work in progress and only available as a private beta.