Ruby 3.4, No More TypeError With **nil As It Is Treated As An Empty Hash.
In Ruby, the splat *
and double splat ** operators are used for handling variable-length arguments in methods, especially when dealing with arrays
and hashes.
The Single Splat operator (*) constructs
and spreads out Arrays.
If we use it when defining a method, it constructs into an array.
def example_method(*args)
puts "args are: #{args}"
end
example_method(3, 5, 7)
# => args are: [3, 5, 7]
If we use it when passing arguments as an array, it deconstructs the array into arguments.
def example_met...
Read more at blog.saeloun.com