Are you sure it needs to be an array? You may be able to use respond_to?(method)
so your code would work for similar things that aren't necessarily arrays (maybe some other enumberable thing). If you do actually need an array
, then the post describing the Array#kind\_of?
method is best.
['hello'].respond_to?('each')