# File lib/map.rb, line 943 def leaf_for(key, options = {}, &block) leaf = self key = Array(key).flatten k = key.first key.each_cons(2) do |a, b| exists = Map.collection_has?(leaf, a) case b when Numeric if options[:autovivify] Map.collection_set(leaf, a, Array.new) unless exists end when String, Symbol if options[:autovivify] Map.collection_set(leaf, a, Map.new) unless exists end end leaf = Map.collection_key(leaf, a) k = b end block ? block.call(leaf, k) : [leaf, k] end