The Refactor Factory 3/7 don't know what to do with my code have tried many diff ways


#1

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

unless n.is_a? Integer
return "n must be an integer."
end

unless 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)


#2

Take a look at examples below
Example: action unless boolean = "n must be an integer."
Example: action if boolean = "n must be greater than 0." { if a <= b}}

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

unless n.is_a? Integer
return "n must be an integer."
end

unless 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)