Actions
Feature #21455
openAdd a block argument to Array#join
Status:
Open
Assignee:
-
Target version:
-
Description
I sometimes come across code like this where
the Array#join
at the end can easily
be overlooked or stands out like a sore thumb:
hex_string = string.bytes.map do |byte|
format('%02X', byte)
end.join(' ')
It seems idiomatic and more succinct
to pass the block to Array#join
directly:
hex_string = string.bytes.join(' ') do |byte|
format('%02X', byte)
end
Pull Request: https://github.com/ruby/ruby/pull/13731
Actions
Like0
Like0Like0Like0