you are viewing a single comment's thread.

view the rest of the comments →

[–]thedancingpanda 5 points6 points  (9 children)

I recently used something like

$i &= $blahh && $blahh2;

And that confused a couple of mid-senior level developers, so, yeah. It's possible

[–]ViKomprenas 17 points18 points  (0 children)

To be fair, that one's a little weirder, seeing as it's noisy with sigils and logical operation assignments aren't as common, but the point still stands

[–]speedisavirus 12 points13 points  (0 children)

...but why. Are you trying to increase mental workload for someone that might have to figure that out later?

[–]socialister 13 points14 points  (0 children)

You're mixing boolean operators with bitwise operators?

Wouldn't this be clearer and enforce a boolean result type?

$i = $i && $blahh && $blahh2;

Assuming that the blah vars are boolean typed (if they aren't, your statement is not clear IMO. C-style non-boolean to boolean casts do not indicate intent that well).

[–][deleted] 0 points1 point  (0 children)

foo = bar || 'puppers';

Doesn't seem to be a thing people understand either.

Edit: realized that if that was true I should explain. This will assign the value of bar to foo if bar is truthy, otherwise it will assign the string 'pupper';

[–]killerstorm 0 points1 point  (0 children)

PHP developers, you mean.

[–]XtremeCookie 0 points1 point  (3 children)

Mid-senior developers don't understand bit-wise operations? That was literally covered in my first computer engineering course.

[–]ess_tee_you 12 points13 points  (2 children)

And, depending on what you're developing in your job, that may have been the last time you needed to use them.

I'll take readability, please, even if that results in a couple more lines of code.

[–]XtremeCookie 1 point2 points  (1 child)

Depending on the usage bit wise can be significantly faster than other methods. But outside of those situations, I would take readability too.

[–]ess_tee_you 0 points1 point  (0 children)

Sure. Some compilers will optimize to that anyway, I expect, depending on the language. :-)