From: Glen Holcomb Date: 2009-09-22T01:27:54+09:00 Subject: Re: Hash or array? --000325559f1a7fdefe047418f621 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On Mon, Sep 21, 2009 at 10:05 AM, Ne Scripter < stuart.clarke@northumbria.ac.uk> wrote: > Hello, > > I have a question, I want to store some data in two columns, for example > > 0001, stuff1 stuff2 > 0002, morestuff > 0003, extrastuff > 0004, more evenmore > > As you can see column 1 is an ID and column 2 is one or more strings. > > I want to do a search across another data set to say if column 1 (ID > number) matches in both sets and the contents of column 2 to data set B. > > I initially thought to use a hash, but it scrambles the order of the > data so was unsure of its efficiency and use. > > Any suggestions? > > Many thanks > -- > Posted via http://www.ruby-forum.com/. > > I'm not sure I completely understand what you are trying to do but with hashes you could do the following: search_value =3D 0003 if hash[search_value] =3D=3D second_hash[search_value] send ahead end if the key doesn't exist the value will be nil so you might want a special case for that. --=20 "Hey brother Christian with your high and mighty errand, Your actions speak so loud, I can=92t hear a word you=92re saying." -Greg Graffin (Bad Religion) --000325559f1a7fdefe047418f621--