From: Andy Lowry Date: 2013-07-23T05:49:53+09:00 Subject: Re: tap { break } idiom deserves its own Kernel method? Tony Arcieri wrote in post #1116271: > On Mon, Jul 22, 2013 at 10:37 AM, Andy Lowry > wrote: > >> I use this idiom from time to time: >> >> x = expr.tap{|value| break expr-involving-value)} >> > > How is this any different than: > > x = expr-involving-value > > ? It's the tap that makes the variable "value" available for use in expr-involving-value. This really mostly comes down to a way to avoid creating method-scoped variables to hold temporary values. The block parameters end up taking their place, which in my opinion makes them less prominent in the code, as they should be. Obviously there's nothing earth-shattering going on here. Just something I believe would be a nice and very small addition. -- Posted via http://www.ruby-forum.com/.