bbatsov/ruby-style-guide — pull request #65 by amiel (2012-01-06 21:07:08+00:00)
Title: Add requirement of parens when using assignment in a conditional.

See discussion on bbatsov/ruby-style-guide#53.

There seemed to be support and no opposition for this so I figured I'd go ahead and implement it.

Quoted from bbatsov/ruby-style-guide#53.

> One of the reasons people don't like using assignment within if statements is because of how
> common it is for this to be a mistake.
>
> There's a convention I've used to make it clear that the assignment is intentional:
>
> ```Ruby
> # Intentional assigment
> if (v = array.grep(/foo/))
> ...
> end
>
> # Oops, this should be equality
> if v = 1
> ...
> end
> ```
>
> I like this because it sort of separates the assignment from the conditional, and clarifies the intention.