I found this example of a code block in Coppers book "Beginning Ruby". This should be an example of a custom method for handling code blocks?
def each_vowel(&code_block)
%w{a e i o u}.each { |vowel| code_block.call(vowel) }
end
each_vowel { |vowel| puts vowel }
I just can't see how this works. Is he sending a code block into another code block?
Something about it just doesn't feel right. I get that each
gets the specific items, one at a time, from the array and put it into the vowel
variable, but what happens next?