Download Horizon :: Staff Members :: TheTechGame.com :: XboxMB YouTube


Old 11-27-2010   #21 (permalink)

AIRBORN LLAMA's Avatar
Join Date: Oct 2010
Location: My house!
Posts: 467
Thanks: 220
Default Re: The Ternary Operator

Quote:
Originally Posted by Cheater912 View Post
The code boxes are just examples. The operator just lets you condense statements into a single line.
Cheater, what if you had a multi line if statement

can you still use the ternary operator?
AIRBORN LLAMA is offline Send a message via AIM to AIRBORN LLAMA Send a message via MSN to AIRBORN LLAMA
Reply With Quote


Old 11-27-2010   #22 (permalink)
Cheater912's Avatar
:D
Join Date: Jul 2010
Location: New York
Posts: 5,683
Thanks: 12,223
Default Re: The Ternary Operator

Quote:
Originally Posted by AIRBORN LLAMA View Post
Cheater, what if you had a multi line if statement

can you still use the ternary operator?
It depends what's in the statement. The ternary operator is mainly for setting booleans.

You can wrap a function around it or set something equal to it, but it must be a bool.
__________________
Cheater912 is offline Send a message via Skype™ to Cheater912
Reply With Quote


Old 11-27-2010   #23 (permalink)

AIRBORN LLAMA's Avatar
Join Date: Oct 2010
Location: My house!
Posts: 467
Thanks: 220
Default Re: The Ternary Operator

Quote:
Originally Posted by Cheater912 View Post
It depends what's in the statement. The ternary operator is mainly for setting booleans.

You can wrap a function around it or set something equal to it, but it must be a bool.
Oh, i see.

So it would need to be a true or false statement in order to use the ternary operator.

Ok, that makes sense, and does keep the coding lines minimum, but i could see places where this funciton might not be as neccessary.

Very handy tho

Thanks!
AIRBORN LLAMA is offline Send a message via AIM to AIRBORN LLAMA Send a message via MSN to AIRBORN LLAMA
Reply With Quote


Old 11-27-2010   #24 (permalink)
Banned
 
Join Date: Oct 2010
Location: Paperville, IL
Posts: 926
Thanks: 565
Default Re: The Ternary Operator

Oh I get it.

Jk. Lol Wut?
Biga is offline Send a message via ICQ to Biga Send a message via AIM to Biga Send a message via Yahoo to Biga Send a message via Skype™ to Biga
Reply With Quote


Old 06-19-2011   #25 (permalink)
Regular Member
 
Join Date: Oct 2010
Posts: 3
Default Re: The Ternary Operator

Isnt this all about: If this condtion is true, then do this, if it isnt then do this. So the statements of if, then, if.


I think its also difficult use this if there are many if/else statements in the logic, right? So if you have a code that needs too be often updated; it is not the best choice?


The trick should be to using the ternary operator to understand that a value is returned by the expression and that the value must be handled as you would handle a value-returned by a function or subroutine;;;
Kristianzhe is offline
Reply With Quote




Old 12-02-2011   #26 (permalink)
TSO
Regular Member
 
Join Date: Nov 2011
Posts: 63
Thanks: 15
Default Re: The Ternary Operator

Quote:
Originally Posted by AIRBORN LLAMA View Post
Cheater, what if you had a multi line if statement

can you still use the ternary operator?
Depends but if you had multiple if statement you could just use a Switch statement but that also varies depending how specific the cases are.
TSO is offline
Reply With Quote


Old 12-03-2011   #27 (permalink)
Regular Member
Intenzitey's Avatar
Join Date: Jun 2011
Location: C:\Windows
Posts: 119
Thanks: 15
Default Re: The Ternary Operator

This is very cool. I may use it in a few tools that i wish to make sometime.
__________________
Get 50 Posts [X]
Get 100 Posts [X]
Get 150 Posts []
Help Others on Xboxmb [Always Trying]
Intenzitey is offline Send a message via AIM to Intenzitey Send a message via Skype™ to Intenzitey
Reply With Quote


Old 02-04-2012   #28 (permalink)
Regular Member
Iccccy's Avatar
Join Date: Oct 2011
Location: Chicago, IL
Posts: 2,544
Thanks: 1,444
Default Re: The Ternary Operator

Quote:
Originally Posted by raghubodi View Post
One common use of the ternary operator in the C# language and other C-like languages is to initialize a variable with the result of the expression. At compile time, the C# compiler translates the ternary expression into branch statements such as 'brtrue'.


However, the high-level ternary statement is useful because it allows you to condense multiple if-statements and reduce nesting. It does not actually eliminate branching but simplifies the high-level representation of the branching at the level of the source code.
Holy Bump :/
Iccccy is offline Send a message via AIM to Iccccy Send a message via Skype™ to Iccccy
Reply With Quote


Old 02-04-2012   #29 (permalink)
Regular Member
sgt frankieboy's Avatar
Join Date: Nov 2010
Location: Netherlands
Posts: 2,391
Thanks: 1,738
Default Re: The Ternary Operator

Quote:
Originally Posted by Iccccy View Post
Holy Bump :/
This is a stickied thread...
__________________


Minecraft World Editor - [BETA] YTMP
Programming Resources

Quote:
Originally Posted by Rich Cook
Programming today is a race between software engineers striving to build bigger and better
idiot-proof programs, and the Universe trying to produce bigger and better idiots.
So far, the Universe is winning.
sgt frankieboy is online now Send a message via ICQ to sgt frankieboy Send a message via AIM to sgt frankieboy Send a message via MSN to sgt frankieboy Send a message via Yahoo to sgt frankieboy Send a message via Skype™ to sgt frankieboy
Reply With Quote
The following users thanked this post: Experiment5X, godzcheater, Jeremy Q

Reply

Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 09:16 AM.


 

Powered by vBulletin® Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
COPYRIGHT (c) 2010 - 2012 - XboxMB - DESIGN BY:
EDENWEBS.COM