Ruby Developer Question:
Tell me how do you remove nil values in array using ruby?

Answer:
Array#compact removes nil values.
Example:
>> [nil,123,nil,"test"].compact
=> [123, "test"]
Example:
>> [nil,123,nil,"test"].compact
=> [123, "test"]
Previous Question | Next Question |
Do you know how Ruby looks up a method to invoke? | Tell us how would you implement hash in Ruby internally? |