On Nov 16, 2007 10:12 AM, Robert Klemme <shortcutter / googlemail.com> wrote:
> 2007/11/16, Sean O'Halpin <sean.ohalpin / gmail.com>:
> > I also find myself using this pattern:
> >
> >   if response = http.response # i.e. expecting nil or false on failure
> >     response.foo
> >     # etc.
> >   else
> >     ...
> >   end
>
> I seriously dislike the pattern above for the following reasons: it
> can be easily misread as "if response == http.response" and there is
> no need to have an assignment inside an if condition.

[snip]

> The situation is different with loops because there often this is the
> most elegant solution:
>
> while line = gets
>  ...
> end
>

Well, I don't really see the difference myself - but then I am
conditioned by C so I tend not to mix = and == up.
However, if you think it's a little tricksy, then I'll certainly
consider changing my practice. After all, code is written for other
people, not for yourself.

Regards,
Sean

> use.inject do |as, often| as.you_can - without end

I do agree, but you know, that could be taken the wrong way (cf.
ruby-talk:277479 ff. ;)