Very similar. tap will yield the block passed to it then return self:
def tap yield self self end On 9 April 2010 23:10, Anuj Dutta <dutta.a...@googlemail.com> wrote: > > > On 9 April 2010 16:56, Joao Carlos <m...@joao-carlos.com> wrote: > >> I just came across a situation where it would be extremely handy to >> have a method that returns the receiver. >> >> Imagine the following example: >> >> filter = %w(with_votes without_votes).include?(params[:filter]) ? >> params[:filter].to_sym : :self >> Idea.published.send(filter).all >> >> The implementation would be pretty simple: >> >> class Object >> def self >> self >> end >> end >> >> Should this be a part of Rails? >> >> > Doesn't tap method in 1.9 do that already? > > Anuj > > > >> -- >> >> 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 rubyonrails-c...@googlegroups.com. >> To unsubscribe from this group, send email to >> rubyonrails-core+unsubscr...@googlegroups.com<rubyonrails-core%2bunsubscr...@googlegroups.com> >> . >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-core?hl=en. >> >> > > > -- > Anuj DUTTA > > -- > 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 rubyonrails-c...@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-core+unsubscr...@googlegroups.com<rubyonrails-core%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-core?hl=en. > -- Ryan Bigg / Radar -- 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 rubyonrails-c...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.