The Rubyist's Loop


Hey there,

I am doing the refractor exercise and until now in every exercise I typed in the exact solution, still the interpreter won’t accept it. The when i hit get code, i just get the code i already typed in and it is valid. It feels really like codeacademy is making fun of you. Here i substituted the for loop with n.times. Still doesn’t work.

$VERBOSE = nil    # We'll explain this at the end of the lesson.
require 'prime'   # This is a module. We'll cover these soon!

def first_n_primes(n)

return "n must be an integer." unless n.is_a? Integer
return "n must be greater than 0." if n <= 0
  prime_array ||= [] 
  prime =
  n.times { prime_array.push( }




Ditto. Same problem. This is a real drag. how can you learn, if, when you do it right, you are marked “wrong”?


I think the whole set of exercises is buggy. I am currently creating intentional mistakes so I can click “Get code” from the pop-up to advance to the next exercise set.


Same here, really annoying…


Hi. The issue appears to be that in the latest Ruby release was deprecated.

From the documentation “ is now obsolete. Use Prime.instance.each or simply Prime.each.”

I changed the following line:

prime =


prime = Prime.each

and all of the steps in the exercise now work.