forked from processing/processing-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconditional.xml
More file actions
executable file
·75 lines (54 loc) · 1.67 KB
/
conditional.xml
File metadata and controls
executable file
·75 lines (54 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?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><![CDATA[
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><![CDATA[
A shortcut for writing an <b>if</b> and <b>else</b> structure. The conditional operator, <b>?:</b> is sometimes called the ternary operator, an operator that takes three arguments. If the <b>test</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 expression: <br />
<pre>result = test ? expression1 : expression2</pre><br />
is equivalent to this structure: <br />
<pre>if (test) {<br />
result = expression1 <br />
} else { <br />
result = expression2 <br />
}</pre>
]]></description>
<syntax>
<c>test</c> ? <c>expression1</c> : <c>expression2</c>
</syntax>
<parameter>
<label>test</label>
<description><![CDATA[any valid expression which evaluates to true or false]]></description>
</parameter>
<parameter>
<label>expression1</label>
<description><![CDATA[any valid expression]]></description>
</parameter>
<parameter>
<label>expression2</label>
<description><![CDATA[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>