Can someone please help me figure out what is wrong with this code?

prime = Prime.new

n.times {

prime_array.push(prime.next)

}

end

this is the error message: It looks like the first_n_primes method no longer returns the correct value.

Can someone please help me figure out what is wrong with this code?

prime = Prime.new

n.times {

prime_array.push(prime.next)

}

end

this is the error message: It looks like the first_n_primes method no longer returns the correct value.

You seem to have gotten rid of the implicit return here, probably by mistake. The method is supposed to return the array once it's built.

Thank you for responding!

I have this now:

prime = Prime.new

n.times {

prime_array.push(prime.next)

}

end

prime_array

end

but the errors says: (ruby):17: syntax error, unexpected keyword_end, expecting $end

I'm just not getting this one. I've tried a few different things but my current code looks like:

$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 = Prime.new

n.times

{prime_array.push(prime.next) }

prime_array

end

first_n_primes(10)

The error message: (ruby):13: syntax error, unexpected '}', expecting tASSOC

prime = Prime.new

n.times{prime_arry.push(prime.next)}

prime_array

end

first_n_primes(10)

do you guys know what I am doing wrong thats leading to an infinite loop I'm indenting like the video only to fail at seeing it

Following is my code and its working fine.

$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)`

```
``` "n must be an integer." unless n.is_a? Integer

"n must be greater than 0." if n <= 0

prime_array ||= []

prime = Prime.new

n.times {prime_array.push(prime.next)}

prime_array

end

first_n_primes(10)

@amantourage

If you have a problem, please post this in a new thread with your question + code + error message

I had the same problem, but I put spaces in the brackets, and it seems to work. n.times { prime_array.push(prime.next) }