Okay! Time to take off the training wheels.

cube = Proc.new { |x| x ** 3 } [1, 2, 3].map(&cube) # [1, 8, 27]

You’re going to create your very own method that calls your very own proc! We’ll do this in two steps. Use the example above as a syntax reminder.



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

Create a Proc, phrase, that puts "Hello there!". Pass this to greeter instead of a block. (Don’t forget to pass &phrase instead of just phrase!)

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?