I occasionally use Struct class when I am programming with Ruby. From Ruby 2.5, objects can be initialized with keyword arguments if keyword_init: ture is passed to Struct.new. I had used this since then because it is more readable and flexible in most cases.

From Ruby 3.2, keyword arguments are accepted by default.

Film = Struct.new(:title, :director) # `keyword_init: true` is no longer needed from Ruby 3.2
Film.new(title: 'Inception', director: 'Christopher Nolan') # => #<struct Film title="Inception", director="Christopher Nolan">

It’s not such a gorgeous update but it definitely became more natural and convenient!

See Also