Mention what is the difference between procs and blocks?
Answer / 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 |
In how many ways a block is written in Ruby?
Explain about class libraries in ruby?
Tell me how can you declare a block in ruby?
Explain about the command line options?
Explain the difference between nil and false in ruby?
In how many ways items can be added in an array in Ruby?
Mention what is the difference between procs and blocks?
What are advantages of using ruby?
Explain about environment variables present in ruby?
Tell me how can we define ruby regular expressions?
Difference between nil and false in ruby?
Who is the developer of Ruby?