9.Create Your Own!



My code works, but I’m a little confused what my method yields to since there is not a ‘yield block’ as seen in previous exercises. My understanding is that when this code looks for a block to yield to and doesn’t find one, it finishes by running the method with my newly created Proc… When the method first encounters ‘yield’, it doesn’t jump to the block in my Proc, does it?

def greeter()

phrase = Proc.new {puts "Hello there!"}



Hi! @methodsurfer83618 :smiley:
Well, since you called the method with the Proc as the argument, it automatically yielded that to the Ruby console for you.
It doesn’t work unless you call the greeter() with the Proc (converted to a block) as the argument.

Hope this simple explanation helps.


Ok, cool. So then, does the ‘yield’ yield down to where the method greeter() is called?


Exactly!! Keep up the good work. :smiley:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.