James Gray
7/10/2007 12:20:00 PM
On Jul 10, 2007, at 7:10 AM, Jon Stenqvist wrote:
> Hi,
>
> I have a array that looks like this
> Type = [["key","value"],["key..","value.."],["..",".."]]
>
> Now i want to the the display (value) when i have the key, is this
> a OK
> way to do it? Or is there a better way?
Yes. You want the assoc() method:
>> assoc_array = [%w[key1 value1], %w[key2 value2], %w[key3 value3]]
=> [["key1", "value1"], ["key2", "value2"], ["key3", "value3"]]
>> assoc_array.assoc("key2").last
=> "value2"
Hope that helps.
James Edward Gray II