Flowdock
method

try_convert

Importance_1
try_convert(p1) public

Try to convert obj into an array, using to_ary method. Returns converted array or nil if obj cannot be converted for any reason. This method is to check if an argument is an array.

Array.try_convert([1])   # => [1]
Array.try_convert("1")   # => nil

if tmp = Array.try_convert(arg)
  # the argument is an array
elsif tmp = String.try_convert(arg)
  # the argument is a string
end
Show source
Register or log in to add new notes.