The Refactor Factory/ Omit Needless words


#1



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


My code gives me the error :"(ruby):7: syntax error, unexpected tSTRING_BEG, expecting keyword_end
return if n <= 0 "n must be greater than 0."
^"


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

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

  return if n <= 0 "n must be greater than 0."
  
  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

The syntax for that can be found in an earlier exercise and it's also shown in the hint


#3

syntax is wrong
1. remove return
2. puts "........" condition...
don't understood feel free to look back
https://www.codecademy.com/en/courses/ruby-beginner-en-1o8Mb/0/2?curriculum_id=5059f8619189a5000201fbcb

Solution :
replace it


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.