adspace


What is the main difference between procs and blocks?

Answer Posted / Chandra Bhan Singh

In Ruby, Procs (procedure objects) are self-contained chunks of code that can be passed around and executed on demand. They can capture the state of the local variables when defined. On the other hand, Blocks are pieces of code written inside methods or within Proc literals. Blocks are used to pass code as arguments.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the current version of ruby on rails?

949