Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAlphonse Cuccurullo
2,513 PointsIm really terrible at modulos but this is what i got. Also if you can tell me what i am doing wrong here.
2 Answers
Erik Nuber
20,629 Pointsmy_array.select{|i| if i % 2 == 0 puts i}
or like you have it take out the .each .
.select alone will go thru the array.
I believe it will also work if you do the reverse and take .select out as each will itterate the over the array as well. But you definitely don't need both.
Erik Nuber
20,629 PointsThe link just takes you to a page on code academy with an array already defined. Could you please elaborate on what your question actually is? It seems you have a question about Modules within Ruby but, without more info there isn't a way to respond. Here is a link to a Ruby site that explains things fairly nicely.
Alphonse Cuccurullo
2,513 PointsHi there sorry about that.
my_array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
The question it's asking is :Write a loop that only puts the even values of my_array. (Bonus points if you use a one-line if!)
This was my answer. my_array.each.select {|i| i.even? puts i}
And for some reason it's not excepting it.