2010/2/24 Jonathan Nielsen <jonathan / jmnet.us>:
>>
>> def iteration obj
>> =A0if obj.is_a? Hash
>> =A0 =A0obj.each { |new_obj| iteration(new_obj) }
>> =A0else
>> =A0 =A0 # It's not a hash, do stuff with it!
>> =A0end
>> end
>>
>> my_hash.each { |obj| iteration(obj) }
>>
>
> Oops. =A0I fixed line 3 above :)

You could also do

def iter(h,&b)
  h.each do |k,v|
    case v
    when Hash
      iter(v,&b)
    else
      b[v]
    end
  end
end

iter my_hash do |obj|
  p obj
end

Although the disadvantage is that doing it this way the structure
information cannot be evaluated in the block.

Kind regards

robert

--=20
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/