Ok, let's start from the beginning, step by step.

```
prime_array ||= []
prime_array ||= nil
```

This part of the code is badly written, it does not make much sense. Let me explain. This strangely looking operator `a ||= b`

can be expanded to more readable form:

`a || a = b`

So it basically means that if `a`

is a `nil`

or `false`

then assign to `a`

value of `b`

.

Let's get back to our real code, what is the meaning of these two lines? The first line checks if the `prime_array`

is `nil`

or `false`

, and if this is true it changes the value of `prime_array`

to an empty list. That makes sense (sort of). But now we know that value of `prime_array`

is certainly not `nil`

or `false`

, so the second line is simply redundant.

Better solution?

`prime_array = [] if prime_array.nil?`

It looks better and is definitely more readable. And it's definitely a better way to handle default values of optional parameters, especially when they are boolean. Don't trust codecademy.

Or:

`prime_array = []`

You always want to calculate list of `n`

first primes, so why not just start with an empty list?

`prime = Prime.new`

This line creates a new instance of class `Prime`

called `prime`

. Classes will be discussed later.

`n.times{ prime_array << prime.next }`

`n`

is the number of primes you want to generate, right? So `n.times`

executes `n`

times the attached block. In this block, Ruby generates the next prime number (`prime.next`

) and then adds it (pushes it) to the array called `prime_array`

.

So the overall effect of this line is that you get the array with `n`

first primes.

`prime_array`

It simply means that this value will be returned as a result of the function.

`first_n_primes(10)`

This line is a function call. It means that we want our function `first_n_primes`

to generate list of the `10`

first prime numbers.