Loops & Iterators


Ok, I've repeatedly tried this exercise in different ways, and I keep getting error messages.


I finally tried copying some code that I found in another message here, that worked for someone else.

And I get the error message:
"undefined method `*' for nil:NilClass"

Please help? I truly appreciate it!

odds = [1,3,5,7,9]
odds.each do x *= 2
    print x


You got it in the example.
First you need to do:
odds.each do |x| and then later you do x *= 2

Click in the assignment down on Hint and you get:

odds.each do |placeholder|
  # Multiply placeholder by 2
  # Print out placeholder


Thank you so much!



This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.