Ruby Developer Question:
Download Job Interview Questions and Answers PDF
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"]
Download Ruby Developer Interview Questions And Answers
PDF
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? |