9. Create Your Own!


#1


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
    yield
end

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

greeter(&phrase)

why not

greeter{&phrase}


#2

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

Hence, greeter(&phrase) suffices.

Hope I helped. :smile:


#3

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:


#4

Check this out:

Do I need to indent my code in Ruby?


#5

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?


#6

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

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