Author Topic: | and & vs || and &&?  (Read 1206 times)

This is ridiculous. Absolutely ridiculous. NO. ITS NOT. YOU'RE WRONG.
== is to test if something equals something else
 =  is to SET SOMETHING to SOMETHING ELSE.

Oh my gosh.
Code: [Select]
x = y
sets x to y and then returns y. The while loop then checks the returned value (y) for truth. That's how simple it is. Another example would be
Code: [Select]
%x = %y = %z;

Code: [Select]
x = y
sets x to y and then returns y. The while loop then checks the returned value (y) for truth. That's how simple it is. Another example would be
Code: [Select]
%x = %y = %z;
so basicaly...
actualy, X = Y returns Y overall
so...
$a = 0;
$b = 1;
$a = $b = 2;
would set everything to 2

in your while loop example, it's returning 1 which is true, and forms the infinite loop

edit: and echo($a = "hi"); echos hi


true, it does stop console errors, but it doesn't change the functionality, does it?
It may in certain circumstances.

for example:

let's say player.addHealth will return the resulting health

if(isObject(player) && player.getDatablock().getName() $= "PlayerTest")

The functionality will not change, as getDatablock is strictly for returning data. In fact, you want it to short circuit because you don't want that .getdatablock returning an error if player doesn't exist.

however

if(player.getDatablock().getName() $= "PlayerTest" && player.addHealth(25) >= 80)
The player will never gain the health if they aren't the PlayerTest datablock.

Oh my gosh, even Ipquarx had to correct someone.

if(player.getDatablock().getName() $= "PlayerTest" && player.addHealth(25) >= 80)
The player will never gain the health if they aren't the PlayerTest datablock.
i was thinking of that in java, but i didn't see any functions that would do it in BL, thanks

Oh my gosh, even Ipquarx had to correct someone.
I don't understand why you think so lowly of me.

Ontopic, here is what the bitwise operators do:

The bit wise operators work on lengths of bits, 1's and 0's.

For example, the & operator looks through each bit from both arguments, and if both are true, sets the corresponding bit in the result to 1. Ex:
1001011010 &
0101001001 =
0001001000

Here are the bitwise operators:
&
^
~
|

This is the topic for you: http://forum.blockland.us/index.php?topic=178383.0
Just noticed I made a few mistakes in that topic (can't edit them). Most of the 1 << 2 bits should be 1 << 1 and so forth.