Hash question

map.keys.each |a| { person.a = rs.Fields(map[a]).Value }
produces this error:

D:/Apps/Ruby/projects/OutlookContact.rb:29: odd number list for Hash

Can anyone help? I’m not sure what this error message means. I’m still
getting used to Ruby syntax, so I might be doing something VERY wrong. Below
is the entire method :slight_smile:

-Dwayne

*** Here’s the entire method, which doesn’t compile.

def addContact3 (rs)
person = @@contactFolder.Items.add( 2 )
1.upto(rs.RecordCount) {
map.keys.each |a| { person.a = rs.Fields(map[a]).Value }
}
rs.moveNext
end

map.keys.each |a| { person.a = rs.Fields(map[a]).Value }

                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is interpreted as an Hash, you must write

   map.keys.each {|a| person.a = rs.Fields(map[a]).Value }
                   ^^^^

now it's interpreted as a block

D:/Apps/Ruby/projects/OutlookContact.rb:29: odd number list for Hash

This error message is for this

pigeon% ruby -e 'hash = { 1 }'
-e:1: odd number list for Hash
pigeon%

pigeon% ruby -e 'hash = { 1, 2 }'
pigeon%

pigeon% ruby -e 'hash = { 1, 2, 3 }'
-e:1: odd number list for Hash
pigeon%

Guy Decoux