Quark Oddities

Quark Oddities

22M Downloads

Stop using &= for booleans

Vexatos opened this issue ยท 2 comments

commented

In Java, a &= b translates to a = a & b, meaning b will be evaluated even if a is already false. Not only does this cause some unnecessary calls, these calls may cause further issues like the error message mentioned in #272 (and MightyPirates/OpenComputers#2192), which specifcally errors here. Please change all uses of a &= b to a = a && b to make your code stop calling things that may not be safe to call.

commented

I don't get how the right side of the linked line would be unsafe to call, unless calling a method on your TE automatically destabilizes said TE. The null check is still short circuiting because && associates more tightly than the &=

commented

The mentioned error was a result of such a call. isUseableByPlayer is normally never called on the client, even though there is no explicit statement that it shouldn't be done.