Control quiz, each_char question

“To strive, to seek, to find, and not to yield.”.each_char do |ch|
puts “Who’s talking about yield?”
puts “That topic’s for a later date!”
end
What does the above code snippet return?

Can someone explain to me why it would return
“To strive, to seek, to find, and not to yield.” instead of nil?
since in the body of the method, it doesn’t really have “ch”, and for puts statement, the returned value is nil.
Thanks in advance!

The each_char method is a “side effect” method that returns the original string.

In the example you gave, each_char will perform its side effect (the two puts statements) one time for each character in the original string, and then return the original string.

You are correct that puts methods return nil, however each_char always returns the original string.