From: duerst@...
Date: 2016-01-19T06:15:22+00:00
Subject: [ruby-core:72926] [Ruby trunk - Feature #12006] [Open] return IO object from IO#print, IO#puts, IO#close_read, IO#close_write, ...

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>