Prime.new is obsolete - how to rewrite this code?

This code finds the first prime number that has 500 divisors. When I run it it work, but I am told that "Prime::new is obsolete. use Prime::instance or class methods of Prime."

I thought this meant that I can replace 'Prime.new' with 'Prime.instance', but when I do that I'm told that 'next is an undefined method'. Since prime should be an enumerator, why am I getting this error? This right answer is 76576500.

Try replacing Prime.new with Prime.instance and each instance of primes.next with primes.succ.

See the source code for the Prime class. You will find that Prime.next is aliased to Prime.succ but Prime.next has no implementation itself. The behavior changes a bit depending on how you create an instance of Prime, which is why you get different errors above.

Email codedump link for Prime.new is obsolete - how to rewrite this code?