I reset that exercise, removed the final return keyword and got the same error message. Since we lack a command line console my next step was test a repl of it.

```
$VERBOSE = nil
require 'prime'
def first_n_primes(n)
unless n.is_a? Integer
return "n must be an integer."
end
if n <= 0
return "n must be greater than 0."
end
prime_array ||= []
prime = Prime.new
for num in (1..n)
prime_array.push(prime.next)
end
return prime_array
end
first_n_primes(10)
```

This was the immediate result…

```
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
private method `new' called for Prime:Class
(repl):16:in `first_n_primes'
(repl):23:in `<main>'
```

Turns out `new`

has been aliased to `instance`

which comes packaged as an array so does not need to be initialized. Let’s make that change and see what happens.

```
$VERBOSE = nil
require 'prime'
def first_n_primes(n)
unless n.is_a? Integer
return "n must be an integer."
end
if n <= 0
return "n must be greater than 0."
end
prime_array ||= []
prime = Prime.instance
for num in (1..n)
prime_array.push(prime.next)
end
return prime_array
end
first_n_primes(10)
```

```
undefined method `next' for #<Prime:0x0055da73492f48>
(repl):18:in `block in first_n_primes'
(repl):17:in `each'
(repl):17:in `first_n_primes'
(repl):23:in `<main>'
```

This before even the refactored array_push method. Turns out the array is unnecessary. The instance is a generator. Paring down…

```
require 'prime
def first_n_primes(n)
unless n.is_a? Integer
return "n must be an integer."
end
if n <= 0
return "n must be greater than 0."
end
prime = Prime.instance
return prime.first n
end
first_n_primes(10) #=> [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]
```

Now, removing the last return gives,

```
require 'prime'
def first_n_primes(n)
unless n.is_a? Integer
return "n must be an integer."
end
if n <= 0
return "n must be greater than 0."
end
prime = Prime.instance
prime.first n
end
first_n_primes(10) #=> [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]
```

Which passes muster.