So…What’s a Proc in Ruby?

make_sandwich = {|filling| "bread, " + filling + " cheese" + " bread"}
=> “bread tofu cheese bread”
def list_lunch_menu(proc)
puts "the first item is salad"
puts "the second item is a sandwich with #{"tofu")}"
puts "the third item is soup"
make_sandwich = {|filling| "bread, " + filling + "," " cheese and " + "bread"}list_lunch_menu(make_sandwich)
#=> the first item is salad
#=> the second item is a sandwich with bread, tofu, cheese and bread
#=> the third item is soup
def cake_recipe_volume_converter(ml_of_flour) {|ml_of_sugar| (ml_of_sugar + ml_of_flour)/237}
p cake_recipe_volume_converter(237)
def cake_recipe_volume_converter(ml_of_flour) {|ml_of_sugar| (ml_of_sugar + ml_of_flour)/237}
recipe_volume_1 = cake_recipe_volume_converter(237.0) #establishes variable including our method argumentp #calls the Proc and supplies the block variable#=> 3.5274261603375527 # this is the total volume
def cake_recipe_volume_converter(ml_of_flour) {|ml_of_sugar| (ml_of_sugar + ml_of_flour)/237}
recipe_volume_2 = cake_recipe_volume_converter(433.0)
#=> 6.890295358649789




Media Maker and Digital Creator

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Fauna Engineering: Looking Back at 2019

Lenskart’s Devops Story — Part 2

Go for Data Engineering

20+ Chrome Extensions to Improve Your Productivity

Leading Change with DevOps Institute Global Ambassador, Karen Ferris

Why Python is the Best Choice For Your Fintech and Finance

Python development services for Fintech

Managing Google Cloud App Engine Redirecting Rules (dispatch.yaml)

Digital Transformation Highlights the Need for DevSecOps

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Evan Burton

Evan Burton

Media Maker and Digital Creator

More from Medium

Boys Need to Learn About Menstruation Too

Educators and Challenges in a Post Covid Society

An Intuitive Explanation of VaR and Risk Reward

Morton’s, McDonald’s and an Easy-Bake Oven