| author | |
| committer | |
| log | 5f7dfc357740e765fad3d8deb246b6dd9aef3fc0 |
| tree | 6558502f4bd146f199aed0987ffbc915d078f09e |
| parent | 79460d4a3eef8eb927b02a7eda8bc9999a766672 |
2 files changed, 9 insertions(+), 2 deletions(-)
doc/langref.html.in+3-2| ... | ... | @@ -5498,8 +5498,9 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val |
| 5498 | 5498 | {#header_open|@splat#} |
| 5499 | 5499 | <pre>{#syntax#}@splat(scalar: anytype) anytype{#endsyntax#}</pre> |
| 5500 | 5500 | <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. | |
| 5503 | 5504 | </p> |
| 5504 | 5505 | {#code|test_splat_builtin.zig#} |
| 5505 | 5506 |
doc/langref/test_splat_builtin.zig+6| ... | ... | @@ -7,4 +7,10 @@ test "vector @splat" { |
| 7 | 7 | try expect(std.mem.eql(u32, &@as([4]u32, result), &[_]u32{ 5, 5, 5, 5 })); |
| 8 | 8 | } |
| 9 | 9 | |
| 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 | ||
| 10 | 16 | // test |