From: JB Eriksson Date: 2005-11-23T07:22:57+09:00 Subject: Re: what is the ruby way to do this? ------=_Part_33575_11574634.1132698171826 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 11/22/05, ako... wrote: > > hello, > > i am still learning. in the below code @attributes is a hash table. i > want to add a new value 'a' for a key represented by 'a.key'. i also > want to group values with the same keys in to arrays. thanks for any > help. > > konstantin > > if @attributes.has_key?(a.key) > if @attributes[a.key].is_a?(Array) > @attributes[a.key] << a > else > @attributes[a.key] =3D [@attributes[a.key], a] > end > else > @attributes[a.key] =3D a > end > > > Pardon my question, but isn't the whole point of hashes that every key is unique? ------=_Part_33575_11574634.1132698171826--