Currently my code is as follows
numbers = [1, 2, 3, 4, 5] def pop_three pop = [] 3.times { pop << numbers.pop } return pop end
Is there a way to do what's inside the pop_three method on one line?
Basically I want to do something like numbers.slice(0, 3) , but delete the elements of the array that are in the slice.
Uh ... hmmmm, I think I just realized that I could try a slice!
Brand source share