+ 1

necesito que me solucionen este codigo,soy nuevo en ruby y no se como podria para no tener que sustituir el numero impar por un

https://code.sololearn.com/cn02CA4LWQIg/?ref=app

13th Jul 2022, 8:50 AM
Jesus
5 Antworten
+ 2
I made your code a bit shorter, but I think it is still not what you want: array = [2,4,5,8] arrayP = [] array.each do |x| arrayP = 0 # default if x%2 == 0 arrayP = x end puts arrayP end
14th Jul 2022, 8:40 AM
Paul
Paul - avatar
+ 1
i want that the result is this:[2,4,8]:i think that eliminate the zero,the length of the array is one less and sorry,i am spanish therefore i prefered write in spanish
15th Jul 2022, 4:08 PM
Jesus
+ 1
yes,but alone the pair numbers of this array quit the odd numbers
15th Jul 2022, 4:14 PM
Jesus
+ 1
for example,you have this array:[1,2,4,6],the result array is this:[2,4,6]
15th Jul 2022, 4:17 PM
Jesus
0
the output that i want is this : [2,4,8]
15th Jul 2022, 4:11 PM
Jesus