String literal in condition? What does this mean?


#1


Also heres my code:

$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.is_a? Integer unless "n must be an integer."
puts "n must be greater than 0." if n <= 0
end

prime_array ||= []
prime = Prime.new
n.times {prime_array << (prime.next)}
prime_array
first_n_primes(10)

https://www.codecademy.com/courses/ruby-beginner-en-Zjd2y/0/6?curriculum_id=5059f8619189a5000201fbcb


Replace this line with your code.


#2

unless is the conditional.

"n must be an integer." is the string literal.

A conditional needs a logical expression or comparison of some sort.

What happens when you write,

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

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