From: wolf@... Date: 2018-08-24T19:54:18+00:00 Subject: [ruby-core:88637] [Ruby trunk Feature#15024] Support block in Array#join Issue #15024 has been updated by graywolf (Gray Wolf). Doesn't `#each_slice` create temporary array for each pair? Doesn't seem very efficient. But assuming that does not matter, can I use something similar to produce `%{a b c d}.join { |_,_,i| i.to_s } == "a0b1c2d"`, is there oneliner for this too? The second example was just illustrating what would be passed into the block. I still think having possibility of block returning the separate is nice thing. ---------------------------------------- Feature #15024: Support block in Array#join https://bugs.ruby-lang.org/issues/15024#change-73696 * 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: