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...


How do you remove nil values in array using ruby?



How do you remove nil values in array using ruby?..

Answer / Ravi Prabhat

You can use the `delete_if` method to remove all nil values from an array in Ruby. For example: `my_array.delete_if {|element| element.nil?}`

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Ruby Interview Questions

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?

1 Answers  


What is the difference between ruby 1.9 and ruby 2.0?

1 Answers  


what is the difference extend and include?

1 Answers  


Explain the difference between nil and false in ruby?

1 Answers  


Explain the concepts and capabilities of garbage collection feature of Ruby?

1 Answers  


What is the use of interpolation in ruby?

1 Answers  


What is request.xhr?

1 Answers  


What are Ruby iterators?

1 Answers  


What is rvm?

1 Answers  


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

1 Answers  


Explain Ruby module?

1 Answers  


Does hash use “ #==” or “#eql?” To compare hash keys?

1 Answers  


Categories