After making the changes the code won't run!


<Below this line, add a link to the EXACT exercise that you are stuck at.>

<In what way does your code behave incorrectly? Include ALL error messages.>
After making the changes, the program won’t run. I’m stuck on this lesson.

$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 =
  for num in (1..n)
  prime_array #return removed



Without being certain, by any means, the only thing that makes sense to me is a change of the version of Ruby integrated with the learning shell after the upgrade and migration. In newer Ruby versions .new is replaced with .instance:

prime_array = Prime.instance

But what’s weird in a way is that the methods on instance are also on the class itself.

def first_n_primes(n)
    "n must be an integer." unless n.is_a? Integer
    "n must be greater than 0." unless n > 0
    Prime.first n

If you are determined to make this lesson work, then you will have to research what is current Ruby usage, and what is deprecated or obsolete. I’m pretty convinced that old Ruby will not work and unbeknownst to us is raising exceptions so the SCT hangs.

The abvove should suffice as a workaround, but spoils the lesson. If you can engage with it (the lesson) to get the gist of what it is about you’ll be better for it.


You might be right about Ruby versions , here we are experiencing issues in Codecademy course, and I think exercises in course does not know what version of Ruby I am writing, Let me explain
In one exercise I tried to add a comment, but only single line comment was working, multi line comment was displaying as I’ve written wrong,
Now this is the issue of every second exercise that we ( hopefully other learners too) are writing correct code but still it shows error, when selecting “Get the code” option, it shows exact same code, not even a single space was different.

So I assume, there can be a difference of version if we code in real. . . but in exercises, there is a real bug of NOT ACCEPTING answer.


Exactly! The exercises in the course do not know what version of Ruby to except. Therefore, we get stuck even if we add in the right answers. This issue is serious because it’s taking me hours to move on to the next exercises. I feel drained mentally. I’m just sitting almost the whole day waiting to see " get code" to submit and move on to the next lesson. It’s quite frustrating :confused: Please fix it. Thank you!


Hahahahaha, :rofl::joy: exactly, for last two days after 5 p.m.(my local time), exercises start to do these kind of things, then I do the same thing . .wait for the “get code” box to move on.


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