Programming Ruby 3.2 (5th Edition): B4.0 page 598, $_ + $_dup.chop() + PP.pp(self, ''.dup)

@noelrappin

page 598, in Shortcuts

  • A. bullet Kernel#chomp says :

$_ (the result of the most recent expresssion)

But

 r = 1 + 2
 puts $_.inspect # => nil

pages 232, 451, 459 all describe $_ as the most recent line input by gets or readline

  • B. in bullet Kernel#chop, missing dot after $_ in $_dup.chop()

  • C. Kernel.pretty_inspect : something wrong in PP.pp(self, ".dup)

Yeah, that’s a wrong description, I was confusing it with underline in irb.

Thanks

@noelrappin

There were three things in page 598, A. B. and C… It seams you have answered only A.

B. in Kernel#chop , should be $_.dup.chop()
C. ".dup

All fixed in next release.

(By the way, the book is going to production in the next 48 hours or so, so further corrections may not get to be made, or at least not until after copy edit)

Thanks – You’ll be mentioned in the Acknowledgements for the book for all your work catching all these errors.

Noel