From: "Aleksi Niemelä" Date: 2000-06-13T18:05:05+02:00 Subject: [ruby-talk:03372] Re: chomp! Uh, there surely is something interesting things with chop-family. Could somebody tell why plain chop isn't working like $_.dup.chop! ? I expect the output should not include any "false". @count = 1 def testcase( str ) p "testcase #{@count}" @count += 1 $_ = str.dup a = chop.dup b = $_.dup $_ = str.dup c = ($_.dup.chop!).dup # should be about identical # to plain chop according to # http://dev.rubycentral.com/ref/ # ref_m_kernel.html#chop d = $_.dup p a, b, c, d p a==c, b==d print "\n" end testcase( "foo\n" ) testcase( "foo\n" ) testcase( "foo\n" ) outputs: "testcase 1" "foo" "foo" "foo" "foo\n" true false "testcase 2" "foo" "foo" "foo" "foo\n" true false "testcase 3" "foo" "foo" "foo" "foo\n" true false