A
Abe.Burnett
It's actually only a block that's doing something I didn't quite catch
as I was working through the previous four chapters.
Here's the block:
verb = 'rescued'
['sedated','sprinkled','electrocuted'].
each do |verb|
puts "Dr. Cham " + verb + " his niece Hannah."
end
puts "Yes, Dr. Cham " + verb + " his niece Hannah."
My question:
What exactly is the relationship between verb and the following array
which is followed by a period? What does the period do? I get the
feeling some sort of shortcut is taking place in those two lines but
I'm not sure what it is. Is there another way of putting it that will
help me see how it's working?
Thanks in advance!
Regards,
Abe
as I was working through the previous four chapters.
Here's the block:
verb = 'rescued'
['sedated','sprinkled','electrocuted'].
each do |verb|
puts "Dr. Cham " + verb + " his niece Hannah."
end
puts "Yes, Dr. Cham " + verb + " his niece Hannah."
My question:
What exactly is the relationship between verb and the following array
which is followed by a period? What does the period do? I get the
feeling some sort of shortcut is taking place in those two lines but
I'm not sure what it is. Is there another way of putting it that will
help me see how it's working?
Thanks in advance!
Regards,
Abe