On Thu, Mar 17, 2011 at 6:02 PM, Yu-Hsuan L. [email protected]
I read the RDoc and it says:
For each object, directly writes obj.inspect followed by the current
output record separator to the programs standard output.
But my $\ is surely nil, it still append a newline after output.
(“output record separator” is $, right?)
Why does it do this?
Looking into Ruby 1.8.7’s source code I see this in io.c:
rb_p(obj) /* for debug print within C code */
This is the function called by the function defined as ‘p’. As you can
see it’s outputting the rb_default_rs. Searching for this in the
source, it’s only assigned to here, in io.c:
rb_rs = rb_default_rs = rb_str_new2("\n");
So it seems it’s assigned to “\n”. I don’t know if this rb_default_rs
is assigned to something else somewhere else (a grep -r rb_default_rs
- only shows the assignment I showed above), maybe someone with more
knowledge can chime in. If this is not the case, then I guess the
documentation should say “the default record separator”. Anyone?