Raised This Month: $32 Target: $400
 8% 

[TUT/INFO] Condition operator aka ? and :


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
stupok
Veteran Member
Join Date: Feb 2006
Old 10-25-2008 , 17:58   Re: [TUT/INFO] ? and : function
Reply With Quote #13

Code:
server_print("%s: %d kill%s", kname, g_Kills[k] > 1 ? "s" : "")

->

Code:
server_print("%s: %d kill%s", kname, g_Kills[k] == 1 ? "" : "s")

0 kills
1 kill
2 kills

Also, since this is supposed to be instructive, I think you should simply show two methods of achieving the same result.

Example 1:
Code:
if( x > 1 ) {     y = 1 } else {     y = 0 }

Example 2:
Code:
y = ( x > 1 ? 1 : 0 )

These are equivalent.
stupok is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:39.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode