Mention what is the difference between procs and blocks?
Answer Posted / Naseer Ahmad
In Ruby, both Procs (procedure objects) and blocks are anonymous functions that can capture the local variables of their enclosing scope. However, they have some differences:nn- A block is a piece of code surrounded by keywords do and end. It's always associated with an iterator like each or times, while Proc objects are standalone functions.n- Blocks are not objects until assigned to a variable as a Proc object.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers