Compound data type: Difference between revisions

m
→‎{{header|Wren}}: Changed to Wren S/H
(→‎{{header|Vlang}}: Rename "Vlang" in "V (Vlang)")
m (→‎{{header|Wren}}: Changed to Wren S/H)
 
(7 intermediate revisions by 6 users not shown)
Line 575:
 
=={{header|COBOL}}==
A compound data item description is possible in COBOL as a subdivided record:
<syntaxhighlight lang="cobol">
<syntaxhighlight lang="cobol"> DATA DIVISION.
01 Point.
05 x WORKING-STORAGE pic 9(3)SECTION.
05 y 01 pic 9(3)Point.
05 x USAGE IS BINARY-SHORT.
</syntaxhighlight>
05 y USAGE IS BINARY-SHORT.</syntaxhighlight>
Here the record <code>Point</code> has the subdivisions <code>x</code> and <code>y</code>, both of which are signed 16-bit binary integers.
 
=={{header|CoffeeScript}}==
Line 745 ⟶ 747:
 
=={{header|Elena}}==
ELENA 6.x:
<syntaxhighlight lang="elena">struct Point
{
prop int X : prop;
prop int Y : prop;
constructor new(int x, int y)
Line 951 ⟶ 954:
3 4
</pre>
 
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
CGRect r = {0, 0, 250, 100}
printf @"x = %.f : y = %.f : width = %.f : height = %.f", r.origin.x, r.origin.y, r.size.width, r.size.height
 
HandleEvents
</syntaxhighlight>
{{output}}
<pre>
x = 0 : y = 0 : width = 250 : height = 100
 
</pre>
 
 
=={{header|Go}}==
Line 1,129 ⟶ 1,146:
Y__P
20</syntaxhighlight>
 
=={{header|Jakt}}==
<syntaxhighlight lang="coboljakt">
01struct Point. {
x: i64
y: i64
}
 
fn main() {
println("{}", Point(x: 3, y: 4))
}
</syntaxhighlight>
 
=={{header|Java}}==
Starting with Java 14 you can use a record
<syntaxhighlight lang="java">
record Point(int x, int y) { }
</syntaxhighlight>
Usage
<syntaxhighlight lang="java">
Point point = new Point(1, 2);
int x = point.x;
int y = point.y;
</syntaxhighlight>
<br />
Alternately
We use a class:
<syntaxhighlight lang="java">public class Point
Line 1,269 ⟶ 1,310:
{A.last {R}}
-> 2
</syntaxhighlight>
 
=={{header|Lang}}==
<syntaxhighlight lang="lang">
&Point = {
$x
$y
}
</syntaxhighlight>
 
Line 2,752 ⟶ 2,801:
 
=={{header|Wren}}==
<syntaxhighlight lang="ecmascriptwren">class Point {
construct new(x, y) {
_x = x
9,476

edits