What is the "sys.stdout.write()" equivalent in Ruby?

Viewed 22769

As seen in Python, what is the sys.stdout.write() equivalent in Ruby?

4 Answers

Here is a one liner for both writing and reading to/from stdin and stdout.

$ ruby -e '$stdout.write "hi\n" '
hi

$ echo "somestring" | ruby -e 'p  $stdin.read'
"somestring\n"

$ echo "somestring" | ruby -e 'puts   $stdin.read'
somestring
Related