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 |
Tell me how you can list all routes for an application?
Explain about Float, Dig and Max?
What is the difference between calling super and calling super()?
What's the difference in scope for these two variables: @name and @@name?
Explain each of the following operators and how and when they should be used: ==, ===, eql?, Equal?
Is ruby a statically typed or a dynamically typed language?
In how many ways items can be removed from array in Ruby?
How would you freeze an object in ruby? Can you provide a simple example?
Tell me an array [1,2,34,5,6,7,8,9], product it using a method?
How to use sql db or mysql db. Without defining it in the database.yml
Tell me how can you declare a block in ruby?
Explain how can we define ruby regular expressions?