Endless Method Definition in Ruby
A new method definition was introduced in Ruby 3.0, the endless definition.
You're probably familiar with:
def do_something(number)
number * 2
end
Of course, we can express this as a one-liner previously as:
def do_something(number); number * 2; end
Now you have the option to write it like this:
def do_something(number) = number * 2
Or another example:
def thing(x) = @thing = x
If you'd like to know more, here is where the spec was discussed
Tweet