From: mame@... Date: 2018-08-25T05:05:21+00:00 Subject: [ruby-core:88642] [Ruby trunk Feature#15024] Support block in Array#join Issue #15024 has been updated by mame (Yusuke Endoh). I'd like somewhat to agree with the motivation. Indeed, I sometimes feel I want to insert separators between each pair of elements. However, I cannot remember the concrete situation, and how often I have encountered the situation. The motivation examples in this ticket look too artificial, so not convincing to me. Could you show us a more real-world use case? Personally, I don't think it is a good idea to extend `Array#join`. It is specialized to generation of a string, but I'm unsure if it is enough. And, the block parameters `|before, after, index|` look too ad-hoc to me. Passing an index is a role of `each_with_index`. It is not a responsibility of `join`, I think. ---------------------------------------- Feature #15024: Support block in Array#join https://bugs.ruby-lang.org/issues/15024#change-73700 * Author: graywolf (Gray Wolf) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- I think it could be handy to have block support in Array#join. For example ```ruby > 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 ```ruby > %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. -- https://bugs.ruby-lang.org/ Unsubscribe: