String literal in condition? What does this mean?


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

prime_array ||= []
prime =
n.times {prime_array << (}

Replace this line with your code.


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."

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