On Thu, Aug 4, 2016 at 1:25 PM, Jedrin <[email protected]> wrote: > Someone once tried to convince me that something like the following is bad > form: > > if obj = get_client > .. > end > > Not sure why it matters that much or if it should always be avoided .. any > thoughts ? > > This used to be very typical in C
Yes, and it was considered bad form there too. In both cases, it leads one to wonder, did the author *mean* to assign, or just forget the extra = in ==? If the code structure is such that you pretty much HAVE to do that, then put a comment to that effect. I've also seen many people slap parens around the assignment, i.e., "if (obj = get_client)", in *both* languages -- that will shut up the warnings some C compilers would otherwise (rightfully) generate. -- Dave Aronson, consulting software developer of Codosaur.us, PullRequestRoulette.com, Blog.Codosaur.us, and Dare2XL.com. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAHxKQijtf7HCvXMHt7PK4s8h7p_2gUUCRPORfKfuOdOH8Cu1Tw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

