Having trouble passing a proc to my function


#1



https://www.codecademy.com/courses/ruby-beginner-en-L3ZCI/1/4?curriculum_id=5059f8619189a5000201fbcb


Hello everyone :slight_smile: ,

I'm having some trouble figuring out how to pass a proc to my function .

(Error message: "Oops, try again.
It looks like you didn't print anything to the console. Did you call your greeter method and pass it the phrase proc?")

Anyone know where I messed up ?


Replace this line with your code. 
def greeter
    yield
  end

phrase = Proc.new do |greeter|
    puts "Hello there!"
end

Thanks in advance,


#2

a proc is another block of method
u had to pass the method, greeter into it in another step
because the way you doing it, you cannot pass other argument to the proc and hence it defeats the purpose of being a proc


#3

Managed to fix my code using your advice. Thanks a lot my friend


#4

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