Project

General

Profile

Actions

Feature #21455

open

Add a block argument to Array#join

Added by leoarnold (Leo Arnold) 1 day ago. Updated 1 day ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:122612]

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


Related issues 1 (1 open0 closed)

Related to Ruby - Feature #21386: Introduce `Enumerable#join_map`OpenActions
Actions #1

Updated by leoarnold (Leo Arnold) 1 day ago

  • Description updated (diff)
Actions #2

Updated by leoarnold (Leo Arnold) 1 day ago

  • Description updated (diff)
Actions #3

Updated by mame (Yusuke Endoh) 1 day ago

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0