[ruby-core:72926] [Ruby trunk - Feature #12006] [Open] return IO object from IO#print, IO#puts, IO#close_read, IO#close_write, ...

From: duerst@...
Date: 2016-01-19 06:15:22 UTC
List: ruby-core #72926
Issue #12006 has been reported by Martin D端rst.

----------------------------------------
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 D端rst
* 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>

In This Thread

Prev Next