Ruby - Arrays
Which of the following Ruby expressions correctly removes nil values from the array [1, nil, 2, nil, 3]?
Which of the following Ruby expressions correctly removes nil values from the array [1, nil, 2, nil, 3]?
compact method removes all nil values from an array and returns a new array without them.delete(nil) removes all nils but modifies the original array and returns the last deleted element, not the array. remove and filter are not valid methods for this purpose.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions