iteration.mon : wrong hash key/value
wade-fs opened this issue · 2 comments
When I execute iteration.mon, I got wrong :
Hash: key
Foo
Steve
Hash: key/value
Bar => Foo
Bar => Foo
When I rewrite script to:
_h = { "Foo": "Bar", "Steve": "Kemp", "Name": "Wade" }
puts( "Hash: key\n")
foreach key in h {
puts( "\t", key, "\n");
}
hh = { "Foo": "Bar", "Steve": "Kemp", "Name": "Wade" }
puts( "Hash: key/value\n")
foreach key,val in hh {
puts( "\t", key, "\t=>\t", val, "\n");
}_
I got:
Hash: key
Steve
Foo
Steve
Hash: key/value
Bar => Foo
Kemp => Steve
Wade => Name
OK there is something going wrong here. So your first example is this:
h = { "Foo": "Bar", "Steve": "Kemp", "Name": "Wade" }
puts( "Hash: key\n")
foreach key in h {
puts( "\t", key, "\n");
}
That produces:
Hash: key
Steve
Name
Name
So the issue there seems to be that the first entry was skipped, and the second was duplicated. I'll take a look now.
(The second example you post I think is the same. The first item is skipped, and the second is repeated.)