FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   Question Mark "?" couldn?t find it in the refernce
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: Question Mark "?" couldn?t find it in the refernce  (Read 337 times)
stylefetish


Question Mark "?" couldn?t find it in the refernce
« on: Jun 21st, 2004, 10:59am »

but came across it quiet some times. what is it for? how to use it?
Thanks in advance!
« Last Edit: Jun 21st, 2004, 10:59am by stylefetish »  
Koenie

170825270170825270koeniedesign WWW Email
Re: Question Mark "?" couldn?t find it in the refe
« Reply #1 on: Jun 21st, 2004, 11:08am »

People call it the trinary operator, and it works as a shortcut if-else statement. It basically works like this: Code:
(expression) ? statement1 : statement2;

If expression is true, statement1 will happen and else statement2 will happen. Here is an example:
Code:
String b = (c != 5) ? "c isn't five!" : "c is five!";

 
Hope this helps!
Koenie
 

http://koeniedesign.com
stylefetish


Re: Question Mark "?" couldn?t find it in the refe
« Reply #2 on: Jun 21st, 2004, 11:37am »

exelent! This helps a lot and is exactly what I needed :-D
 
kevinP

Email
Re: Question Mark "?" couldn?t find it in the refe
« Reply #3 on: Jun 21st, 2004, 11:18pm »

on Jun 21st, 2004, 11:08am, Koenie wrote:
People call it the trinary operator...

 
But more people call it the ternary operator.
 

Kevin Pfeiffer
Pages: 1 

« Previous topic | Next topic »