mirror of
https://github.com/processing/processing4.git
synced 2026-02-12 10:00:42 +01:00
67 lines
1.5 KiB
XML
67 lines
1.5 KiB
XML
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
<root>
|
|
<name>?: (conditional)</name>
|
|
|
|
<category>Control</category>
|
|
|
|
<subcategory>Conditionals</subcategory>
|
|
|
|
<usage>Web & Application</usage>
|
|
|
|
<example>
|
|
<image></image>
|
|
<code>
|
|
int s = 0;
|
|
for(int i=5; i<100; i+=5) {
|
|
s = (i < 50) ? 0 : 255;
|
|
stroke(s);
|
|
line(30, i, 80, i);
|
|
}
|
|
</code>
|
|
</example>
|
|
|
|
<description>
|
|
A shortcut for writing an <b>if()</b> and <b>else</b> structure. If the <b>condition</b> evaluates to <b>true</b>, <b>expression1</b> is evaluated and returned. If the <b>condition</b> evaluates to <b>false</b>, <b>expression2</b> is evaluated and returned.<br /><br />The following conditional: <br /><pre>condition : expression1 ? expression2</pre><br />is equivalent to this structure: <br /><pre>if(condition) {<br /> expression1 <br />} else { <br /> expression2 <br />}</pre>
|
|
</description>
|
|
|
|
<syntax>
|
|
<c>condition</c> ? <c>expression1</c> : <c>expression2</c>
|
|
</syntax>
|
|
|
|
<parameter>
|
|
<label>condition</label>
|
|
<description>any valid expression which evaluates to true or false</description>
|
|
</parameter>
|
|
|
|
<parameter>
|
|
<label>expression1</label>
|
|
<description>any valid expression</description>
|
|
</parameter>
|
|
|
|
<parameter>
|
|
<label>expression2</label>
|
|
<description>any valid expression</description>
|
|
</parameter>
|
|
|
|
<returns>Variable, dependent on the datatype of the expressions</returns>
|
|
|
|
<related>
|
|
if()
|
|
else
|
|
</related>
|
|
|
|
<availability>1.0</availability>
|
|
|
|
<type>Structure</type>
|
|
|
|
<partof>PDE</partof>
|
|
|
|
|
|
<level>Extended</level>
|
|
|
|
|
|
|
|
|
|
|
|
</root>
|