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 |
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?
What is the difference between ruby 1.9 and ruby 2.0?
what is the difference extend and include?
Explain the difference between nil and false in ruby?
Explain the concepts and capabilities of garbage collection feature of Ruby?
What is the use of interpolation in ruby?
What is request.xhr?
What are Ruby iterators?
What is rvm?
Explain ruby ranges. What are the ways to define ranges?
Explain Ruby module?
Does hash use “ #==” or “#eql?” To compare hash keys?