Define An Endless Method In Ruby

Featured image

Prior to Ruby 3, methods could be defined as follows:

def do_something
  puts "Something!"
end

or

def do_something; puts "Something!"; end

With Ruby 3, methods can be defined without the need for the ‘end’ keyword.

def do_something = puts "Something!"

Endless method definitions are well-suited for one-line methods.