> Isn't #find better than #select?

Yes, I think you are correct.
I am learning too and had not come across find before. Thankyou for  
the information.

Cheers,
Dave

On 18/02/2007, at 11:06 PM, SonOfLilit wrote:

> Isn't #find better than #select?
>
> select wouldn't break the first time a match was found, find would.
> Less time, less memory.
>
> Aur Saraf
>
> On 2/18/07, Sharon Phillips <phillipsds / yahoo.co.uk> wrote:
>> Hi,
>>
>> I think this should do the job
>> nb-=1 if contact.select{|c| c==parameter}.any?
>>
>> it will return nb-1 if any contact matches parameter, or nil if none
>> match
>>
>> cheers,
>> Dave
>>
>>
>> On 18/02/2007, at 10:45 PM, Josselin wrote:
>>
>> > I wrote this code that's running well..
>> >           origin = false
>> >           contact.each {|c|  origin = true  if c.from ==  
>> parameter }
>> >           nb -= 1 if origin
>> >
>> > is there any way to write it in one line ?  (exiting from the bloc
>> > when the condition is true)
>> > something like :
>> >           contact.each {|c|  nb -= 1; exit;  if c.from ==  
>> parameter }
>> >
>> > tfyl
>> >
>> > joss
>> >
>> >
>> >
>>
>>
>>
>