Hi.
ri Kernel#p shows this:
--------------------------------------------------------------- Kernel#p
p(obj, …) => nil
For each object, directly writes _obj_.+inspect+ followed by the
current output record separator to the program's standard output.
S = Struct.new(:name, :state)
s = S['dave', 'TX']
p s
_produces:_
#<S name="dave", state="TX">
But when I run the following:
$cat tmp.rb
print $
$ ruby tmp.rb
nil$
Namely, Kernel#p is expected to print ‘current output record separator’,
but current output separator is just nil.
What I’ve done in the wrong way here? Is the ri document written
wrongly?
Sincerely,
Minkoo S.
On Tuesday 11 July 2006 16:16, Minkoo S. wrote:
S = Struct.new(:name, :state)
print $
$ ruby tmp.rb
nil$
Namely, Kernel#p is expected to print ‘current output record separator’,
but current output separator is just nil.
What I’ve done in the wrong way here? Is the ri document written wrongly?
[email protected] ~> irb
p $
nil
nil
p $/
“\n”
nil
guess you just have a typo there 
remember, the $/ is a jedi that just waits to attack and to slice
output…
it’s not the output being attacked 
stupid way to remember… but maybe it helps - imho one shoulnd’t have
to
remember that stuff anyway
I should have to mention this problem explicitly.
AFAIK, $/ is ‘input record separator’ while $\ is ‘output record
separator.’
And the problem is:
$ruby -e ‘p “a”’
“a”
$
As you can see p is printing new line character. But the spec says that
p is supposed to print ‘output record separator’ after printing out
given
arguments.
Let’s see what current output record separator is…
$ruby -e ‘p $’
nil
$
Surprisingly, $, output record separator, is nil while Kernel#p printed
new
line.
So I guess one of the following holds:
(1) p prints new line instead of output record separator.
(2) Somehow, $\ is converted into newline while Kernel#p is running
(3) $\ is not a output record separator, actually.
Any idea?
On 7/12/06, Logan C. [email protected] wrote:
$ruby -e ‘p “a”’
(2) Somehow, $\ is converted into newline while Kernel#p is running
I think maybe the docs lie. Looking at the C code, p uses
rb_default_rs (when maybe they meant to use rb_output_rs?)
Could anybody tell me where I have to file the bug report on the
document of ‘Kernel#p’?
Sincerely,
Minkoo S.
On Jul 12, 2006, at 12:30 AM, Minkoo S. wrote:
As you can see p is printing new line character. But the spec says
Ack, top posting evil.
$\ is the output record separator if print is any indicator
% cat outputsep.rb
$\ = “:”
print 1
puts
% ruby outputsep.rb
1:
I think maybe the docs lie. Looking at the C code, p uses
rb_default_rs (when maybe they meant to use rb_output_rs?)