What the heck?to be or not to be


#1



hey,something is wrong with this code:


 prime_array = [] def my_method(n)
  n ||= 3
 if  n < 29
  puts n
  end
  my_method(5)
  my_method(nil)


and here's the error:
(ruby):13: syntax error, unexpected keyword_def, expecting keyword_end
prime_array = [] def my_method(n)
^
(ruby):28: syntax error, unexpected $end, expecting keyword_end


#2

In the first line you assign empty array to prime_array variable and you try to define method - you shouldn't do both things in one line. Additionally interpreter says, you lack keyword end somewhere in your code.


#3

it did type it right but the system tells me that i didn't use the conditional assignment operator.
heres my code
prime_array = []
def my_method(n)
n ||= 3
if n < 29
puts n
end
my_method(5)
my_method(nil)
end


#4

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