9. Create Your Own!


This seems to be the answer, but I thought yield should be pass into a function call using {},
here the greeter takes no parameter, why would () work?

def greeter

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


why not



Why not the curly braces should be because you're calling that function, greet.

Hence, greeter(&phrase) suffices.

Hope I helped. :smile:


Is there a reason why this particular section of code is on three separate lines? Or is it just preference? I have my set of code to have everything on one line, so it looks like:


Check this out:

Do I need to indent my code in Ruby?


I'm stuck with this problem too. I don't understand the explanation given in this thread. Maybe you can explain a little more in detail? Thanks!

Edit: If I pass a block I use { } and if I pass a Proc I use ( ). Is that correct?


Create a method, greeter, that takes no arguments and yields to a block.

so just add something after yield
yield [0,0,0]