什么是正确的方法:
is_array("something") # => false (or 1) is_array(["something", "else"]) # => true (or > 1)
还是要计算其中的项目数?
您可能想使用kind_of().
kind_of()
>> s = "something" => "something" >> s.kind_of?(Array) => false >> s = ["something", "else"] => ["something", "else"] >> s.kind_of?(Array) => true