Wraps its argument in an array unless it is already an array (or array-like).
If the argument is nil an empty list is returned.
Otherwise, if the argument responds to to_ary it is invoked, and its result returned.
Otherwise, returns an array with the argument as its single element.
This method is similar in purpose to Kernel#Array, but there are some differences:
It does not call to_a on the argument, but returns an empty array if argument is nil.
The second point is easily explained with some enumerables:
There’s also a related idiom that uses the splat operator:
The differences with Kernel#Array explained above apply to the rest of objects.
# File activesupport/lib/active_support/core_ext/array/wrap.rb, line 36 def self.wrap(object) if object.nil?  elsif object.respond_to?(:to_ary) object.to_ary || [object] else [object] end end