9.2 Method Syntax


#1

I do not understand this at all. What am I meant to do? :scream:


#2

bolu001...all you need to do is to add 'def' to replace the first ___ and 'end' to replace the second___.


#3

When I saw puts, I had no idea what was going on, thank you.


#4

I don't get it. What am I missing

def number
puts 1..10
(1..10).each { |i| puts i }
end

puts_1_to_10 # Ignore this for now. We'll explain it soon!


#5

Hello...

The main issue with this example is the actual Method name, the instructions simply state to replace the underscores "_" with the proper syntax to run the code, and when you look at the code you find the following:

__ puts1_to_10
(1..10).each { |i| puts i }


puts_1_to_10 # Ignore this for now. We'll explain it soon!

what you have to keep in mind is that "puts_1_to_10" is the method name, and not intended to be turned into "puts" syntax for execution, so the first instant of this name is used to define the name of the method, and the second one next to the comment, is used to call the method and execute it. So the solution would look something like this:

def puts_1_to_10
(1..10).each { |i| puts i }
end

puts_1_to_10 # Ignore this for now. We'll explain it soon!

I hope this helps, best of luck.


#6

I put end for the second ___ and i get an error message