I am stuck on Codecademy, Learn Ruby, 7 Refactoring, The Refactor Factory, 7/7.

Here’s a link to the exercise: https://www.codecademy.com/courses/learn-ruby/lessons/the-refactor-factory/exercises/nice-work-2?action=lesson_resume

The Codecademy Ruby window won’t run any of the code for this exercise … I can’t even get Codecademy to run the initially provided code for 1/7. It seems to stall here. I initially discovered this in Google Chrome and the I’m having the same issue with Firefox. I recall that Codecademy just updated their Ruby course … could this change be the source of my problem? I couldn’t get Codecademy to work, so I tried things out in my desktop interactive Ruby and also my command line and I still have problems. The error I receive is "Prime::new is obsolete. use Prime::instance or class methods of Prime. Replacing Prime.new from line 26 of my code doesn’t fix the problem; it causes another problem. The “next” from line 29 of my code “n.times {prime_array << (prime.next) }” isn’t a method … my command line spits out "undefined method ‘next’ for #Prime:0x2563b60 .

Here is my code with my comments:

```
=begin
"The Refactor Factory" project is the concluding exercise for the Learn Ruby unit 7 track called "Refactoring."
This work is part of Codecademy's Full Stack Web Developer Program that I am working on.
This exercise provides you with poorly written Ruby code for a program that generates a list of prime numbers
up to the entered ending number.
=end
require 'prime' #This pulls in the Ruby prime module.
#first_n_primes is our program name and it accepts the integer n, which it's called with at the end of the program.
def first_n_primes(n)
#is_a? Integer is used to check if the submitted number is an integer. An error is reported otherwise.
#The original code had a 3 line unless statement here that I've updated to be a single-line if statement.
return "n must be an integer." unless n.is_a? Integer
#Prime numbers are integers that are non-negative, so an error is thrown if a positive # isn't submitted.
#I've replaced the three line if statement from the initial version with this single-line if statement.
return "n must be greater than 0." if n <= 0
#Here the variable prime_array is defined as an array if it hasn't already been defined to be something
#See the original code, file with "initial" tagline instead of "refactored," for the inclusion
#of the "if prime_array.nil?" Here I use the conditional assignment operator to simplify that code.
prime_array ||= []
#
prime = Prime.instance
#There was an uncessary for loop here. I've replaced it with a simpler n.times.
#.push can be simplified with the concatenation operator (<<).
n.times {prime_array << (prime.next) }
prime_array
#There was a "return prime_array" that I removed. It wasn't necessary because the prime_array was just evaluated.
end
first_n_primes(10)
```

Thanks for any help you can provide