From: Michael Fellinger Date: 2007-09-04T16:47:07+09:00 Subject: Re: with On 9/4/07, Nobuyoshi Nakada wrote:> Hi,>> At Tue, 4 Sep 2007 00:15:32 +0900,> Matthias W辰chter wrote in [ruby-talk:267357]:> > Is there something like "with" already available? Let me give the> > short implementation first so the gurus know right away what I am after:> >> > module Kernel> > def with> > yield self> > end> > end>> "tap" in 1.9 is same. They have different effects, while 'tap' will return self and throwaway results of the block, 'with' returns the result of the block. [manveru@pi ~]$ RUBYOPT= irb19class Object def with yield(self) endend# nil1.tap{|e| e + 1} + 2# 31.with{|e| e + 1} + 2# 4 ^ manveru