Hi, One of the fundamental methods share by both ActiveSupport and Facets is Hash#slice!. A few days ago, someone pointed out to me that the two libs in this case are not quite the same. Quote, "I got hosed by a lovely bug stemming from facets'' and rails'' slice! returning opposite things... facets returns the key,value pairs not matched by the keys passed, great because it gives you two things back at once, though slice and slice! return different things. rails returns the key,value pairs matched, that is, slice and slice! have the same return" Generally I let Facets defer to the behavior of ActiveSupport when there is a conflict, but in this case the Facets implementation seems more useful and is also more in line to similar methods in core Ruby, ie. Array#slice!, which also returns the deleted items. So I was hoping that Rails could be modified to support this alternate implementation of Hash#slice!. Thanks, T. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 1 Sep 2008, at 00:28, Thomas Sawyer <rails-mailing-list@andreas- s.net> wrote:> > Hi, > > One of the fundamental methods share by both ActiveSupport and > Facets is > Hash#slice!. A few days ago, someone pointed out to me that the two > libs > in this case are not quite the same. Quote, "I got hosed by a lovely > bug > stemming from facets'' and rails'' slice! returning opposite things... > facets returns the key,value pairs not matched by the keys passed, > great > because it gives you two things back at once, though slice and slice! > return different things. rails returns the key,value pairs matched, > that is, slice and slice! have the same return" > > Generally I let Facets defer to the behavior of ActiveSupport when > there > is a conflict, but in this case the Facets implementation seems more > useful and is also more in line to similar methods in core Ruby, ie. > Array#slice!, which also returns the deleted items. > > So I was hoping that Rails could be modified to support this alternate > implementation of Hash#slice!. >Best place to discuss this is the rubyonrails-core mailing list. Regardless of which way is "better" any change will have backwards compatibility implications. Fred> Thanks, > T. > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> Best place to discuss this is the rubyonrails-core mailing list. > Regardless of which way is "better" any change will have backwards > compatibility implications.Thanks Fred. Your right it will have compatibility issues. However if Matz is ever inclined to add Hash#slice! to Ruby itself, I am pretty certain it will return the diff. Moreover, it is likely that very few have used the return value slice! b/c it would be rather redundant (ie. why would use #slice! when #slice works?) I tried signing up to core list, but it is moderated and haven''t been contacted yet. Hopefully soon. T. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---