Skip to content

Instantly share code, notes, and snippets.

/io.c Secret

Created October 31, 2012 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/53a3156da467a20d497b to your computer and use it in GitHub Desktop.
Save anonymous/53a3156da467a20d497b to your computer and use it in GitHub Desktop.
Prints obj on the given port (default $>).
Equivalent to:
def display(port=$>)
port.write self
end
For example:
1.display
"cat".display
[ 4, 5, 6 ].display
puts
produces:
1cat456
static VALUE
rb_obj_display(int argc, VALUE *argv, VALUE self)
{
VALUE out;
if (argc == 0) {
out = rb_stdout;
}
else {
rb_scan_args(argc, argv, "01", &out);
}
rb_io_write(out, self);
return Qnil;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment