Given an array like:
[1, 2, nil, nil, 3, nil, 4, 5, 6, nil, nil, nil]
id wanted to remove nil from the end of the array. It's not hard to solve some ugly loops, but I was hoping this would be a Ruby way.
Result: [1, 2, nil, nil, 3, nil, 4, 5, 6]
source share