On Nov 12, 2007 12:58 PM, Josh Susser <josh / hasmanythrough.com> wrote: > > Ruby's enumeration message names come directly from its Smalltalk > ancestry. There are also some aliases. Like so: > > *method* *alias* > collect map > detect find > select find_all > reject > inject > > Ruby 1.9 introduces the K-combinator in the form of the method > Object#tap. I don't get the name #tap at all. So I'm proposing a new > name/alias pair, with a more meaningful name: > > *method* *alias* > affect tap > > "foo".affect { |s| s << "bar" } > #=> "foobar" > > The K-combinator is all about side-effecting the receiver object, so > "affect" seems like a meaningful name for that functionality (whereas > "effect" would be wrong!). "tap" is still cute, and rhymes with "map", > so having both seems like a good Rubyish way to go. Of course, active-support also defines the same method as Object#returning I'm not sure how the Smalltalk intro ties in here. I can't recall a method implementation of the k-combinator in common use in Smalltalk, in most cases the message cascade syntax ending with an invocation of #yourself, would serve the cases where the k-combinator is used: Ruby a = MyObject.new.tap do |o| # or returning, or affect o.foo = 1 o.bar = "whatever" end Smalltalk a = MyObject.new foo: 1; bar: "whatever"; yourself For Rubyists unfamiliar with Smalltalk, the message cascade triggered by the ; meant send the message after the ; to the receiver of the last message. Object#yourself was defined to return the receiver, and was not typically overridden. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/