From: kwest Date: 2007-06-14T03:40:16+09:00 Subject: Re: Ruby Hash Querying OK I answered my own question...sorry. But here is the answer in case someone else asks the same silly question: Use a string as a key (doh!) @documentnames = { 'finance_whitepaper' => 'whitepaper one', 'ecommerce_whitepaper' => 'whitepaper two', 'integratedsvs_datasheet' => 'whitepaper three' } Problem solved! On Jun 13, 11:30 am, kwest wrote: > Hello, > I am new to Ruby and have run into a small snag. I have a hash like > so: > > @documentnames = { > :finance_whitepaper => 'whitepaper one', > :ecommerce_whitepaper => 'whitepaper two', > :integratedsvs_datasheet => 'whitepaper three' > } > > So I am trying to then go like so: > > @documentnames[k] > > where k is a variable in a loop with the key from the has minus the > ":" in front > > But if I try to add the ":" in front > > <%key = ':' + k%> > > And then try to reference the element > > <%= @documentnames[key] %> > > I get a null value....