How to create method?


Create a method, greeting, in the editor. It should use puts to print a greeting to the console.


Since you read the instructions, I'm sure you can read the example given as well, here it is:

Now it's time for you to build your own method. Remember, the syntax looks like this:

def method_name
  # Do something!

Try to make something work and we'll discuss it.


def greeting sentence
put "{#sentence}"

this code is returning "wrong number of arguments (0 for 1)" in the console.
I think I am not understanding the concept of method and calls. can you please explain.


A method is just a bit of code that you define beforehand (using the def/end keywords) in order to reuse it later on.

Once your method is defined, you can call it whenever you need it using its name (and passing it arguments if it accepts some).

They were just asking you to define a method, not to give it arguments, that's why they were calling greeting without any argument.

Since you defined your greeting with an argument (sentence), it gives an error, because then the call to greeting is made without passing any argument.

Just define a method without any argument, like the one given in the example.