Skip to content

Commit 5f7dfc3

Browse files
kiedtlalexrp
authored andcommitted
langref: update splat section
1 parent 79460d4 commit 5f7dfc3

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

doc/langref.html.in

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5498,8 +5498,9 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
54985498
{#header_open|@splat#}
54995499
<pre>{#syntax#}@splat(scalar: anytype) anytype{#endsyntax#}</pre>
55005500
<p>
5501-
Produces a vector where each element is the value {#syntax#}scalar{#endsyntax#}.
5502-
The return type and thus the length of the vector is inferred.
5501+
Produces an array or vector where each element is the value
5502+
{#syntax#}scalar{#endsyntax#}. The return type and thus the length of the
5503+
vector is inferred.
55035504
</p>
55045505
{#code|test_splat_builtin.zig#}
55055506

doc/langref/test_splat_builtin.zig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,10 @@ test "vector @splat" {
77
try expect(std.mem.eql(u32, &@as([4]u32, result), &[_]u32{ 5, 5, 5, 5 }));
88
}
99

10+
test "array @splat" {
11+
const scalar: u32 = 5;
12+
const result: [4]u32 = @splat(scalar);
13+
try expect(std.mem.eql(u32, &@as([4]u32, result), &[_]u32{ 5, 5, 5, 5 }));
14+
}
15+
1016
// test

0 commit comments

Comments
 (0)