Simple handling of 1 or many method arguments

It's pretty common to have a method which accepts either a single value, or an array of values. In the method body, it's not hard to detect whether you've been passed an array or not, but you can actually do this in Ruby without any conditionals.

def test( args )
  Array( args )
end

>> test( 1 )
=> [1]
>> test( [ 1, 2 ] )
=> [1, 2]

Taking this one step further, it's pretty simple to handle multiple arguments in the same manner.

def test( *args )
  Array( args ).flatten
end

>> test( 1 )
=> [1]
>> test( [ 1, 2 ] )
=> [1, 2]
>> test( 1, 2 )
=> [1, 2]

I think you can make a good case that this isn't necessarily great API design, but it's nice to have something as simple as Array() when it's appropriate.