What's this symbols ? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: What's this symbols ? (
/showthread.php?tid=257352)
What's this symbols ? -
Ricop522 - 25.05.2011
":" "?"
pawn Код:
new a;
a = 1;
if(a == 1) : print("a == 1!") ? print("a == 0!");
Is this correct?
Whats ?, :, and
What's return 0x1 ? is return 1; ??
Re: What's this symbols ? -
blewert - 25.05.2011
? and
: are
triadic or
ternary operators.
Clickety!
They're handy because you can use them in assignment (or pretty much any statement for that matter), for example:
PHP код:
new bool:a = false;
new b = ( a == false ) ? ( 3 ) : ( 2 );
b would be assigned
3, because
a is evaluated as
false, and it returns
3.
this could also be wrote out as:
PHP код:
new bool:a = false;
new b;
if( a == false )
{
b = 3;
}
else
{
b = 2;
}
The code you posted:
PHP код:
new a;
a = 1;
if(a == 1) : print("a == 1!") ? print("a == 0!");
Isn't correct, the correct way of writing it would be:
PHP код:
new a;
a = 1;
print( ( a == 1 ) ? ( "a == 1!" ) : ( "a == 0!") );
As for 0x1 in the return, yea it's a hexadecimal representation of the value 1. See more about hex & pawn here:
https://sampwiki.blast.hk/wiki/Hex
Re: What's this symbols ? -
cs_master - 25.05.2011
wiki is best
Re: What's this symbols ? -
Ricop522 - 25.05.2011
THANKS alot !