Ticket: https://rails.lighthouseapp.com/projects/8994/tickets/1950

Mike

On Aug 6, 2009, at 7:50 AM, Eloy Duran wrote:

> Yeah creating a proc every time isn't needed and much cleaner this  
> way. I do think that it's better to use #blank? as was used in  
> Ryan's patch. Still waiting for that ticket :)
>
> Eloy
>
> On Aug 6, 2009, at 2:44 PM, Ryan Angilly wrote:
>
>> Similar discussion from an older ticket: 
>> https://rails.lighthouseapp.com/projects/8994/tickets/1815-patch-add-or_if_blank-to-object
>>
>>
>> On Thu, Aug 6, 2009 at 8:38 AM, Luca Guidi <[email protected]>  
>> wrote:
>> What about using Object#try and avoiding the explicit &block  
>> argument?
>> This avoid to instantiate a Proc object *for each* method  
>> execution, if any block isn't passed and the enumerable is empty  
>> the VM will raise a LocalJumpError.
>>
>> module Enumerable
>>   def else
>>     self.try(:empty?) ? yield : self
>>   end
>> end
>>
>> Please look at this benchmark (http://gist.github.com/163274) my  
>> implementation is exactly 4x faster ;)
>>
>> Cheers,
>> Luca
>> -- 
>> lucaguidi.com
>> twitter.com/jodosha
>>
>>
>>


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to