K
Krekna Mektek
Hi,
busy with my script, I am trying to print my hash, which is built up as follows:
hash:
key = A, value = [1,2,3]
key = B, value = [4,5,6]
etc.
I try this:
@h.each do |key,value|
print key, " is ", value.each {|x| print x, " -- " }, "\n"
The print is strange, becuase it looks like this now:
1 -- 2 -- 3 -- A is 123
4 -- 5 -- 6 -- B is 456
I don't understand why. If I interpreted this correctly, I've got the
following two questions:
1. How come the code block is executed first
2. After that the key and value is printed, however, I don't see the
print for the values here (except for the print in de the code block,
which was executed already).
Krekna
busy with my script, I am trying to print my hash, which is built up as follows:
hash:
key = A, value = [1,2,3]
key = B, value = [4,5,6]
etc.
I try this:
@h.each do |key,value|
print key, " is ", value.each {|x| print x, " -- " }, "\n"
The print is strange, becuase it looks like this now:
1 -- 2 -- 3 -- A is 123
4 -- 5 -- 6 -- B is 456
I don't understand why. If I interpreted this correctly, I've got the
following two questions:
1. How come the code block is executed first
2. After that the key and value is printed, however, I don't see the
print for the values here (except for the print in de the code block,
which was executed already).
Krekna