From: Trans Date: 2006-11-17T21:50:09+09:00 Subject: Re: #returning and #tap Joel VanderWerf wrote: > dblack@wobblini.net wrote: > > Hi -- > > > > On Fri, 17 Nov 2006, Joel VanderWerf wrote: > > > >> Coming full circle around the golf course... This last one above is > >> what lead me to prefer #then (== #tap) in the first place: > >> > >> def foo > >> @foo ||= Foo.new.then do |f| > >> f.bar = "bar" > >> end > >> end > >> > >> Also, #then avoids the scoping nastiness of #instance_eval. > > > > I'm not getting the semantics of "then". Do you mean "then" as in, "I > > took off my coat and then sat down", as opposed to then in if/then? > > Yes. Not much better than #tap, is it? Any ideas...? "and_then"? well, #with is the other common synonym. but #returning seems as well. you just read it with the object of returning being stated first, which we sometimes do in english. def foo @foo ||= Foo.new.returning do |f| f.bar = "bar" end end T.