Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

if/else shorthand

Status
Not open for further replies.

stormbind

Technical User
Mar 6, 2003
1,165
GB
Hi,

When I put if (blurb) : a ? b ; to my java compiler it whined, so I went back to using if/else, and it bugs me that I could not write what I wanted.

Was my syntax flawed? [sadeyes]

Also, please post your shorthand tips for Java: maybe this thread can become a valuable reference [worm]

--Glen :)

Memoria mihi benigna erit qui eam perscribam
 
Doh! :wallbash:

Thank you,

--Glen :)

Memoria mihi benigna erit qui eam perscribam
 
BTW, its called a tertiary statement

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
... or a 'ternary conditional'.

Tim
---------------------------
"Your morbid fear of losing,
destroys the lives you're using." - Ozzy
 
Or superman.

Christiaan Baes
Belgium

I just like this --> [Wiggle] [Wiggle]
 
I hate to nit-pick, but I believe
Code:
(blurb) : a ? b;

should be

Code:
(blurb) ? a : b;

The ? and : were out of place.
 
Talking about nit-picking, you can skip the "(" and ")"

blurb ? a : b;

does the trick as well.
 
This small piece of code was just to small to get tested before posting.
I'll have to rework my quality-management-processes.

There is no excuse for the braces of course.
Hm. I'm so ashamed.
I should switch to javascript...

Ha - stop - I found an excuse!

I have been 5 minutes in the kitchen, cooking some coffee, and when I came back, my cat (Idaia) just hit the enter-button.
Normally she is just allowed to partizipate in the 'general unix diskussion'.

seeking a job as java-programmer in Berlin:
 
You have no excuse.

You MUST lock your computer while not working on it.

We hope this won't happen again.

Cheers,
Dian
 
Condemn yourselves to the script monkey forum !!!

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top