Ruby - Arrays
What will be the output of this Ruby code?
arr = [nil, nil, nil] arr.compact! puts arr.inspect
What will be the output of this Ruby code?
arr = [nil, nil, nil] arr.compact! puts arr.inspect
compact! removes all nil values in place and returns nil if no changes were made, otherwise returns the modified array.nil, compact! removes them all, leaving an empty array [].15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions