Why require?


#1



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


I didn't get any error, i'm just wondering what does this " require 'prime' " do?


require 'prime'

def first_n_primes(n)
  # Check for correct input!
  "n must be an integer" unless n.is_a? Integer
  "n must be greater than 0" if n <= 0

  # The Ruby 1.9 Prime class makes the array automatically!
  prime = Prime.instance
  prime.first n
end

first_n_primes(10)


#2

prime is an external module housing the class methods of Prime. It is required because your program is calling on one of its methods, Prime.instance.