What is the syntax for defining a method in Ruby?

What is the syntax for defining a method in Ruby?

روبی میں طریقہ کی وضاحت کے لیے نحو کیا ہے؟
Explanation

In Ruby, the syntax for defining a method is:

def method_name(parameters)

  # method body

end

The 'def' keyword is used to define a method, followed by the method name and parameters in parentheses.

The method body is indented and enclosed by the 'end' keyword.