From: Peter Vandenabeele Date: 2012-02-04T04:11:17+09:00 Subject: Re: Help please Undefined Method error --bcaec5196189b2a9fd04b814133d Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Fri, Feb 3, 2012 at 7:16 PM, Bartosz Dziewo=C5=84ski wrote: > Personally I have no problems using: > > def get_words > ret =3D [] > while !(input =3D gets.chomp).empty? > ret << input > end > return ret > end > > I think that what I also dislike about using #tap in this scenario is > that you have to scan the entire function to see what it returns. In > my example, it clearly returns a variable named ret, and you can > easily look for this name in the code, see it defined and filled. In > your, it returns a value of the block inside, which might return > anything =3D so you scroll to the top, only then see it's a #tap, then > looks for the variable name it uses inside the block, and only now you > see what is this array filled with. > > Obviously which one you prefer is subjective; just my two cents. But > I'm pretty sure that the "declare accumulator, fill it, return it" is > easily recognizable for anyone - complete beginner and a convert from > any other language - while #tap is Ruby-specific and a cryptic for > newbies. > Thank you for the clarification :-) Agree to disagree? Peter --bcaec5196189b2a9fd04b814133d--