Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


In Ruby code, often it is observed that coder uses a short hand form of using an expression like array.map(&:method_name) instead of array.map { |element| element.method_name }. How this trick actually works?



In Ruby code, often it is observed that coder uses a short hand form of using an expression like arr..

Answer / Dinesh Chandra Tripathi

This is called the symbolization shortcut in Ruby. It allows you to pass the method name as a symbol instead of a block. When using &, it dereferences the Proc object from the Symbol and applies it to each element in the array.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Ruby Interview Questions

What is retry statement in ruby?

1 Answers  


What is request.xhr?

1 Answers  


What is ruby?

1 Answers  


Explain about class libraries in ruby?

1 Answers  


Explain ruby ranges. What are the ways to define ranges?

1 Answers  


Explain about interpolation?

1 Answers  


Do you know about dig, float and max?

1 Answers  


What is the scope of a local variable in ruby?

1 Answers  


How to open a file in Ruby?

1 Answers  


Explain ruby strings.

1 Answers  


Mention what is the command to create a migration?

1 Answers  


Explain about operators in Ruby?

1 Answers  


Categories