Issue #12006 has been reported by Martin Drst.

----------------------------------------
Feature #12006: return IO object from IO#print, IO#puts, IO#close_read, IO#close_write,...
https://bugs.ruby-lang.org/issues/12006

* Author: Martin Drst
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
There are a number of methods on IO objects that currently return nil.
It would be more convenient if they returned the object itself; that way, the methods could be chained.

Although some people might disagree with this style, this would allow e.g. to write something like

output = IO.popen(command, 'r+') do |pipe|
  pipe << input
  pipe.close_write
  pipe.read
end

as:

output = IO.popen(command, 'r+') do |pipe|
  pipe.print(input).close_write.read
end




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

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>