matt neuburg wrote: > There seems to be some confusion about the notion of "name" underlying > all of this. There are not really any "names" in this story. Ruby isn't > about "names". It's about pointers. string1_hash doesn't *have* a > "name". It doesn't *need* a name. It is the value of some entry in > big_hash. As long as you have a pointer to big_hash, you will always > have access to its keys and values, and every one of those values is a > hash of arrays, where the key is string1, string2, string3, whatever. > You are there. Ok, I'm learning that everything is an object, everything is a pointer in Ruby. But pointers though not required to have names, have names. It seems to make for more readable code in some circumstances. So here's my snippet: (forgive me, this is the first ruby I've tried so it is probably weak) bigHash = Hash.new { |h,k| h[k] = [] } p4.run_changes("-m5","//depot/path/...").each { |ch| string1 = ch["change"] bigHash[string1] = string1_hash } puts(bigHash.inspect) This iterates 5 times, each time with string1 being equal to a different string, so bigHash has 5 keys. The problem I'm having is that the value of each of the 5 keys is the same - string1_hash. To take an analogy from perl, I would have set $i to 0 and incremented such that when I did: bigHash[string1] = string${i}_hash That would set the value for each unique string1 key to a unique hash, each with unique a name that is meaningful to me and can be easily referenced later. So I guess I just don't know how to assign unique anonymous hashes as the value for each key in bigHash? So I don't care that string1_hash isn't named "string1_hash" - ok, makes sense - but then I guess I'm still asking this question about using one variable's value as another's name. If "no name" hash is the value of bigHash[string1], I guess coming from perl I'm not sure how to de-reference this appropriately, when I have the feeling that I don't need to de-reference anything. I just don't know how to correctly use the syntax to use the hash values of one hash as the thing that they are, a pointer to another hash that I want to populate with keys and values. Maybe I want to do somthing like this? bigHash = Hash.new { |h,k| h[k] = [] } p4.run_changes("-m5","//depot/path/...").each { |ch| string1 = ch["change"] bigHash[string1] = Hash.new { |h,k| h[k] = [] } } puts(bigHash.inspect) -- Posted via http://www.ruby-forum.com/.