I am reading “why’s (poignant) Guide to Ruby”, which is both
entertaining and an excellent introduction to Ruby. In Chapter 5, “Them
What Make the Rules and Them What Live the Dream”, I stumble on such a
obvious error that I start to question myself. Do I understand what he’s
trying to explain?
verb = ‘rescued’
[‘sedated’, ‘sprinkled’, ‘electrocuted’].
each do |verb|
puts “Dr. Cham " + verb + " his niece Hannah.”
end
puts “Yes, Dr. Cham " + verb + " his niece Hannah.”
OUTPUT
Dr. Cham sedated his niece Hannah.
Dr. Cham sprinkled his niece Hannah.
Dr. Cham electrocuted his niece Hannah.
Yes, Dr. Cham electrocuted his niece Hannah.
But I feel very strongly that the last line should be:
Yes, Dr. Cham rescued his niece Hannah.
This part of the book covers scoping issues in particular, so it strikes
me as odd that this mistake happens here. Most of the examples in the
book are rather acurate.