Are there any “simple” explanations of what procs and lambdas are in Ruby?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Lambdas (which exist in other languages as well) are like ad hoc functions, created only for a simple use rather than to perform some complex actions.
When you use a method like
Array#collectthat takes a block in{}, you’re essentially creating a lambda/proc/block for only the use of that method.See Anonymous functions on Wikipedia, and some other SO questions for the nuances of
lambdavs.Proc.