Issue #9807 has been reported by Michael Kohl.

----------------------------------------
Feature #9807: String.new with block
https://bugs.ruby-lang.org/issues/9807

* Author: Michael Kohl
* Status: Open
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
----------------------------------------
After a discussion in our team chat today, I wondered if it would be a good idea to have a version of String.new that accepts a block and works as a string builder. Something like

    string = String.new("foo") do |s|
      s << "bar"
    end
    string #=> "foobar"

If the argument is omitted an empty string would be passed to the block instead.

That could be a nice solution to avoid all the Array#join and "".tap hacks for string creation.



-- 
https://bugs.ruby-lang.org/