Il 21/01/10 14.46, I単aki Baz Castillo ha scritto:
> El Jueves, 21 de Enero de 2010, Jeff Peng escribi坦:
>    
>> 在 2010-01-21四的 22:22 +0900,Iaki Baz Castillo写道:
>>
>>      
>>> Hi, Ruby 1.9 implements "first" method for Hash (as Hash are ordered
>>> now). However the return value if a bit annoying for me. A real example:
>>>
>>> irb>  h = {"aaa"=>"AAA", "bbb"=>"BBB"}
>>> irb>  h.first
>>> ["aaa", "AAA"]
>>>        
>> Since the result is an array you can access its element with the array
>> way:
>>
>> irb(main):007:0>  h.first[1]
>> =>  "AAA"
>>      
> Sure. I just expected Hash#first returning the first valule rather than the
> first [key,value] entry.
>
>    
Hash#first returns the first element.  You can access first value with

h.values.first

Bye,
Andrea
--
ZephirWorks