in reply to puts vs say

I definitely agree with this. say() should be smart. What gain is there really but just adding a \n? Regular old print() is just fine if I have to keep track of the \n anyway.

-Paul

Replies are listed 'Best First'.
Re^2: puts vs say
by Your Mother (Archbishop) on Feb 13, 2021 at 07:48 UTC

    For me it’s preferable to print 90% of the time. One example in particular comes to mind–

    say join ", ", @some_bunch_of_stuff; # vs this which I find incredibly annoying– print join(", ", @some_bunch_of_stuff), "\n";
Re^2: puts vs say
by Anonymous Monk on Feb 28, 2009 at 12:30 UTC
    It was ported from perl6, so it does what perl6 say does.
      I get it. I didn't say it does chomp, I said it should chomp.

      -Paul

        certainly other people would complain if say() chomps automatically!

        so what's wrong with defining your own puts() beside of say()

        DB<13> sub puts {my $x=pop; chomp($x); print @_,$x,"\n"} DB<14> puts 1,2,3,"a\n" 123a DB<15>
        Btw.
        • Does puts() take a list in ruby?
        • Are all elements chomped or just the last one?
        with your own solution you have full control about the behavior...

        Cheers Rolf