forked from processing/processing-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreturn.xml
More file actions
executable file
·109 lines (86 loc) · 2.35 KB
/
return.xml
File metadata and controls
executable file
·109 lines (86 loc) · 2.35 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<root>
<name>return</name>
<category>Structure</category>
<subcategory></subcategory>
<usage>Web & Application</usage>
<example>
<image></image>
<code><![CDATA[
int val = 30;
void draw() {
int t = timestwo(val);
println(t);
}
// The first 'int' in the function declaration
// specifies the type of data to be returned.
int timestwo(int dVal) {
dVal = dVal * 2;
return dVal; // Returns an int of 60, in this case
}
]]></code>
</example>
<example>
<image></image>
<code><![CDATA[
int[] vals = {10, 20, 30};
void draw() {
int[] t = timestwo(vals);
println(t);
noLoop();
}
int[] timestwo(int[] dVals) {
for (int i = 0; i < dVals.length; i++) {
dVals[i] = dVals[i] * 2;
}
return dVals; // Returns an array of 3 ints: 20, 40, 60
}
]]></code>
</example>
<example>
<image></image>
<code><![CDATA[
void draw() {
background(204);
line(0, 0, width, height);
if (mousePressed) {
return; // Break out of draw(), skipping the line statement below
}
line(0, height, width, 0); // Executed only if mouse is not pressed
}
]]></code>
</example>
<description><![CDATA[
Keyword used to indicate the value to return from a function. The value being returned must be the same datatype as defined in the function declaration. Functions declared with <b>void</b> can't return values and shouldn't include a return value.<br />
<br />
The keyword <b>return</b> may also be used to break out of a function, thus not allowing the program to the remaining statements. (See the third example above.)
]]></description>
<syntax><![CDATA[
<c>type</c> <c>function</c> {
<c>statements</c>
return <c>value</c>
}
]]></syntax>
<parameter>
<label>type</label>
<description><![CDATA[boolean, byte, char, int, float, String, boolean[], byte[], char[], int[], float[], or String[]]]></description>
</parameter>
<parameter>
<label>function</label>
<description><![CDATA[the function that is being defined]]></description>
</parameter>
<parameter>
<label>statements</label>
<description><![CDATA[any valid statements]]></description>
</parameter>
<parameter>
<label>value</label>
<description><![CDATA[must be the same datatype as the "type" parameter]]></description>
</parameter>
<returns></returns>
<related>
</related>
<availability>1.0</availability>
<type>Keyword</type>
<partof>PDE</partof>
</root>