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
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.