Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
September 20, 2018, 12:28:18 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register Chat  
Pages: [1]   Go Down
  Print  
Author Topic: The Conditional Operator  (Read 1802 times)
SiriusA
Newbie
*
Posts: 22


« on: July 13, 2009, 10:16:59 PM »

Great book! I tried Obj-C 6 months ago with an O'Reilly book and it was just too obtuse. This text, however, is working out great for me.

Anyhow, perhaps this is premature, but I'd be interested in knowing why the "conditional operator" device/syntax is more useful than just running if/then statements. Clearly there's more to come in later chapters but can anyone summerize thoughts on it's value? I suppose it's more concise but, in that, less easily readable IMO.

Thoughts?
Logged
webwrx
Newbie
*
Posts: 41


« Reply #1 on: July 13, 2009, 11:48:54 PM »

It took me a while to appreciate it too, but now I think it's pretty cool if you have a very short and simple If/Then/Else expression to evaluate. Anything more than that I'd always go for the longhand version.

I'm up to chapter 12 and I can see how the conditional operator becomes handy when you start getting into Macros (see examples page 245).

Cheers,
Ben
Logged
skochan
Administrator
Hero Member
*****
Posts: 3114



« Reply #2 on: July 14, 2009, 06:22:20 AM »

Yes, because it's an operator and not a statement, it can be used in places where an if/else can't.  As noted by Ben, macros are a perfect case in point.

Cheers,

Steve Kochan
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents ゥ 2009 classroomM.com. All rights reserved.