25.05.2011, 15:59
(
Последний раз редактировалось blewert; 26.05.2011 в 08:11.
)
? 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:
b would be assigned 3, because a is evaluated as false, and it returns 3.
this could also be wrote out as:
The code you posted:
Isn't correct, the correct way of writing it would be:
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
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 );
this could also be wrote out as:
PHP код:
new bool:a = false;
new b;
if( a == false )
{
b = 3;
}
else
{
b = 2;
}
PHP код:
new a;
a = 1;
if(a == 1) : print("a == 1!") ? print("a == 0!");
PHP код:
new a;
a = 1;
print( ( a == 1 ) ? ( "a == 1!" ) : ( "a == 0!") );
https://sampwiki.blast.hk/wiki/Hex