user1804592 user1804592 - 1 year ago 72
Ruby Question

Delete all even numbers from an array (Ruby)?

I'm doing the Ruby Monk tutorial to further some ruby learning and I got stumped on what should be an easier question. I know the answer is right in front of me but I cannot seem to figure it out:

Delete all the even numbers from the array given below:
[1, 2, 3, 4, 5, 6, 7, 8, 9]

Any help would be great!


Here it is.

a = [1, 2, 3, 4, 5, 6]
a.delete_if &:even?