A method definition is Ruby source code that declares a method’s name, parameters, and executable behavior. It gives an object an action that can later be requested through a method call. section 2.1.3 section 2.1.1
A parameterized conversion method
def obj.c2f(c) c * 9.0 / 5 + 32 end puts obj.c2f(100) # 212.0 Here, c is the formal parameter, while 100 is the argument supplied by the call. The method returns the value of its final expression. section 2.1.3
Parameters appear after the method name, usually in parentheses, and correspond positionally to arguments in the call. Parentheses may be omitted in simple definitions and calls, although keeping them can clarify chained or ambiguous expressions. Empty parentheses are valid for methods without arguments but are commonly omitted. section 2.1.3
Several Ruby mechanics shape how method definitions behave:
- Every method call returns a value; a definition can use its final expression as that result. section 2.1.3
- A method definition itself evaluates to the symbol naming the newly defined method, even when calling that method would return false. section 7.5.1
- A top-level definition becomes a private instance method of Kernel and is therefore available as a bareword-style call to objects. section 5.5
- Ruby can interpret a bare identifier as a local variable or method call; unresolved names raise a NameError. section 2.5.4
def obj.c2f(c)
c * 9.0 / 5 + 32
end
Inspect the complete method definition used for the conversion example, including its receiver, parameter, body, and terminating end. section 2.1.3



















