There's often a need to accept a variable number of arguments. You might have done it like this:
if object_or_objects.respond_to? :each
objects = object_or_objects
objects = [object_or_objects]
Sounds familiar? Well there are a number of ways that work better with this kind of pattern.
First one accepts either 1 argument or many arguments (and can be combined with standard arguments).
# method(a) or method(a, b, c)
# method([a, b, c]) #=> [[a, b, c]]
# can be solved by calling the method as follows:
# method(*[a, b, c]) #=> [a, b, c]
# objects is always an array
Second one accepts only 1 argument, but whether the argument is a single object or an array of objects, it will be treated as an array.
# method(a) or method([a, b, c])
# method(a, b, c) #=> invalid number of arguments
objects = Array(object_or_objects) # or the less readable = [*object_or_objects]
There you go, now you can handle as many arguments as you like and deal with them as if they were always an array.