ruby Ruby Hash深度搜索没有获得堆栈大小异常

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ruby Ruby Hash深度搜索没有获得堆栈大小异常相关的知识,希望对你有一定的参考价值。

class Hash
  def deep_find(key, object=self, found=nil)
    if object.respond_to?(:key?) && object.key?(key)
      return object[key]
    elsif object.is_a? Enumerable
      object.find { |*a| found = deep_find(key, a.last) }
      return found
    end
  end
end

以上是关于ruby Ruby Hash深度搜索没有获得堆栈大小异常的主要内容,如果未能解决你的问题,请参考以下文章