Methods without "end"
Originally a joke, to reduce the number of end
and « V » code. Ruby 3 finally introduced endless methods when there’s only one expression.
Since Ruby 3.1, parentheses are no longer mandatory in the expression. However, they are for method parameters. The expression can be written on several lines if needed.
⚠️ The =
corresponding to an assignment respects the priority rules. What do you think the following code produces?
Links to Ruby documentation for endless method
and the history of issue 16746.