Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Tech Support (https://forums.graalonline.com/forums/forumdisplay.php?f=7)
-   -   Another Operator Precedence Issue! (https://forums.graalonline.com/forums/showthread.php?t=63362)

jake13jake 01-11-2006 03:53 PM

Another Operator Precedence Issue!
 
this.mode != "jumping"
is not the same as !this.mode == "jumping"
apparently.

ApothiX 01-11-2006 04:40 PM

Quote:

Originally Posted by jake13jake
this.mode != "jumping"
is not the same as !this.mode == "jumping"
apparently.

and it shouldn't be. You are saying the not of this.mode (which is a boolean) equals jumping (which is a string) So it -should- always return false, no matter what. To fix this just do: !(this.mode == "jumping")

Skyld 01-11-2006 06:28 PM

Quote:

Originally Posted by jake13jake
this.mode != "jumping"
is not the same as !this.mode == "jumping"
apparently.

Why would it be?

Unless you're surrounding it with brackets, it's treating !this.mode == "jumping" effectively as Not this.mode equal to "jumping", which probably will be even more senseless as "jumping" is not a boolean.

ApothiX 01-11-2006 06:35 PM

Quote:

Originally Posted by Skyld
Why would it be?

Unless you're surrounding it with brackets, it's treating !this.mode == "jumping" effectively as Not this.mode equal to "jumping", which probably will be even more senseless as "jumping" is not a boolean.

That's exactly what I said, Mister Skyld.

jake13jake 01-11-2006 09:38 PM

So it tests as a boolean when comparing to a string value and as a floating point when comparing to a floating point? I'm so confused.

ApothiX 01-11-2006 09:44 PM

Quote:

Originally Posted by jake13jake
So it tests as a boolean when comparing to a string value and as a floating point when comparing to a floating point? I'm so confused.

... what? '!' is a boolean operator, I think !this.stringvalue tests if the string is set or not, ie:

PHP Code:

temp.stringval "Wee";
if(
temp.stringval) echo("This should fire.");

temp.stringval ""// or unset("temp.stringval");
if(!temp.stringval) echo("This should also fire."); 


Lance 01-11-2006 11:54 PM

Quote:

Originally Posted by jake13jake
So it tests as a boolean when comparing to a string value and as a floating point when comparing to a floating point? I'm so confused.

You're only negating the left side of the comparison (this.mode) in your second case, which (assuming this.mode is a string) is negating a string.

Do you understand how negating a string could cause a problem?


All times are GMT +2. The time now is 11:50 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.