From: Thimios Dimopulos Date: 2013-04-27T20:22:51+09:00 Subject: unsubscribe --047d7b3a7f102800ef04db55df29 Content-Type: text/plain; charset=ISO-8859-1 On Sat, Apr 27, 2013 at 12:42 PM, Michel Demazure wrote: > Robert Klemme wrote in post #1106648: > > > > What is it that you want to achieve? Can you please come up with a more > > realistic example? > > > > Kind regards > > > > robert > > Hello Robert. I use this systematically, replacing for instance > > def foo(args) > hsh = Hash.new > ## some lines building hsh by calling methods using args, > hsh > end > > by > > def foo(args) > Hash.new.tap do |hsh| > ## same code as above > end > end > > I find the latter cleaner and easier to read, due to the extra > indentation inside. I think Rails has a 'returning' method doing just > that. > > _md > > -- > Posted via http://www.ruby-forum.com/. > > --047d7b3a7f102800ef04db55df29 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable



On Sat, Apr 27, 2013 at 12:42 PM, Michel Demazure <lists@ruby-f= orum.com> wrote:
Robert Klemme wrote in post #1106648:
>
> What is it that you want to achieve? =A0Can you please come up with a = more
> realistic example?
>
> Kind regards
>
> robert

Hello Robert. I use this systematically, replacing for instance

def foo(args)
=A0 hsh =3D Hash.new
=A0 ## some lines building hsh by calling methods using args,
=A0 hsh
end

by

def foo(args)
=A0 Hash.new.tap do |hsh|
=A0 =A0 ## same code as above
=A0 end
end

I find the latter cleaner and easier to read, due to the extra
indentation inside. I think Rails has a 'returning' method doing ju= st
that.

_md

--
Posted via http://= www.ruby-forum.com/.


--047d7b3a7f102800ef04db55df29--