Project

General

Profile

Actions

Feature #12006

open

return IO object from IO#print, IO#puts, IO#close_read, IO#close_write,...

Added by duerst (Martin Dürst) about 8 years ago. Updated about 8 years ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:72926]

Description

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

Actions

Also available in: Atom PDF

Like0
Like0