Return value of pp

e$B1sF#$G$9!#e(B

p e$B$,0z?t$rJV$9$h$&$K$J$C$?$N$G!“e(Bpp e$B$b$=$l$K$”$o$;$k$He(B
e$B$$$$$H;W$&$N$G$9$,!"$I$&$G$7$g$&$+!#e(B

Index: lib/pp.rb

— lib/pp.rb (revision 16560)
+++ lib/pp.rb (working copy)
@@ -54,12 +54,12 @@
private

prints arguments in pretty form.

  • pp returns nil.

  • pp returns argument(s).

    def pp(*objs) # :doc:
    objs.each {|obj|
    PP.pp(obj)
    }
  • nil
  • objs.size <= 1 ? objs.first : objs
    end
    module_function :pp
    end

In article
[email protected],
“Yusuke ENDOH” [email protected] writes:

p e$B$,0z?t$rJV$9$h$&$K$J$C$?$N$G!“e(Bpp e$B$b$=$l$K$”$o$;$k$He(B
e$B$$$$$H;W$&$N$G$9$,!"$I$&$G$7$g$&$+!#e(B

e$B$=$&$7$?>l9g!"e(Birb e$B$Ge(B pp e$B$r;H$C$?$H$-$K!"e(Bpp
e$B$NI=<(7k2L$K2C$(e(B
e$B$Fe(B inspect e$B$J7k2L$,=P$F$-$F!"8+$K$/$$$s$8$c$J$$$G$9$+$M$’!#e(B

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:34830] return value of pp”
on Sat, 24 May 2008 00:53:02 +0900, “Yusuke ENDOH” [email protected]
writes:

|p e$B$,0z?t$rJV$9$h$&$K$J$C$?$N$G!“e(Bpp e$B$b$=$l$K$”$o$;$k$He(B
|e$B$$$$$H;W$&$N$G$9$,!"$I$&$G$7$g$&$+!#e(B

e$B;[email protected]$7$^$9!#%3%_%C%H$7$F$/[email protected]$5$$!#e(B

e$B1sF#$G$9!#e(B

08/05/24 e$B$Ke(B Tanaka A.[email protected] e$B$5$s$O=q$-$^$7$?e(B:

p e$B$,0z?t$rJV$9$h$&$K$J$C$?$N$G!“e(Bpp e$B$b$=$l$K$”$o$;$k$He(B
e$B$$$$$H;W$&$N$G$9$,!"$I$&$G$7$g$&$+!#e(B

e$B$=$&$7$?>l9g!"e(Birb e$B$Ge(B pp e$B$r;H$C$?$H$-$K!"e(Bpp e$B$NI=<(7k2L$K2C$(e(B
e$B$Fe(B inspect e$B$J7k2L$,=P$F$-$F!"8+$K$/$$$s$8$c$J$$$G$9$+$M$’!#e(B

e$B$&!<$s!"e(Bpretty_inspect e$B$,Dj5A$5$l$F$$$k$H$-$O!“e(Birb
e$B$N7k2LI=<($K$be(B
pretty_inspect e$B$r;H$&!”$H$$$&$N$G$I$&$G$7$g$&$+!#e(B

irb(main):001:0> [“foo bar baz”] * 6
=> [“foo bar baz”, “foo bar baz”, “foo bar baz”, “foo bar baz”, “foo
bar baz”, “foo bar baz”]
irb(main):002:0> require “pp”
=> true
irb(main):003:0> [“foo bar baz”] * 6
=> [“foo bar baz”,
“foo bar baz”,
“foo bar baz”,
“foo bar baz”,
“foo bar baz”,
“foo bar baz”]

Index: lib/pp.rb

— lib/pp.rb (revision 16560)
+++ lib/pp.rb (working copy)
@@ -54,12 +54,12 @@
private

prints arguments in pretty form.

  • pp returns nil.

  • pp returns argument(s).

    def pp(*objs) # :doc:
    objs.each {|obj|
    PP.pp(obj)
    }
  • nil
  • objs.size <= 1 ? objs.first : objs
    end
    module_function :pp
    end
    Index: lib/irb.rb
    ===================================================================
    — lib/irb.rb (revision 16560)
    +++ lib/irb.rb (working copy)
    @@ -299,7 +299,13 @@

    def output_value
    if @context.inspect?

  •    printf @context.return_format, @context.last_value.inspect
    
  •    value = @context.last_value
    
  •    if value.respond_to?(:pretty_inspect)
    
  •      str = value.pretty_inspect.chomp
    
  •    else
    
  •      str = value.inspect
    
  •    end
    
  •    printf @context.return_format, str
     else
       printf @context.return_format, @context.last_value
     end