Project

General

Profile

Actions

Feature #15024

open

Support block in Array#join

Added by graywolf (Gray Wolf) about 6 years ago. Updated about 6 years ago.

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

Description

I think it could be handy to have block support in Array#join.

For example

> puts %w{a b c d}.join { |_, _, i| i % 2 == 1 ? "\n" : ', ' }
a, b
c, d

not sure what arguments exactly the block should take, atm I'm thinking
of

> %w{a b c d}.join { |before, after, i| puts "#{before}:#{after}:#{i}" }
a:b:0
b:c:1
c:d:2

Would appreciate some feedback before I try putting together patch for this.


Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #14022: String#surroundRejectedActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0