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

Is ruby a statically typed or a dynamically typed language?

1 Answers  


In how many ways you can compare Ruby string?

1 Answers  


Tell us how would you implement hash in ruby internally?

1 Answers  


Where does a scope change in a ruby program?

1 Answers  


Do you know what is the defined operator?

1 Answers  


What is concatenating string in Ruby?

1 Answers  


Tell me how you can list all routes for an application?

1 Answers  


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

1 Answers  


What is sysread method in Ruby?

1 Answers  


Explain some differences between ruby and python.

1 Answers  


Tell me what is the difference between calling super and calling super()?

1 Answers  


Explain about methods?

1 Answers  


Categories