Skip to content
Sign in
Computer SPSC

What is the syntax for defining a method in Ruby?

Tap an option to check the answer. You can also press A–D.

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.