mirror of
https://github.com/ziglang/zig.git
synced 2025-12-16 03:03:09 +00:00
parent
3f3003097c
commit
a5c96c49d0
@ -760,7 +760,7 @@ pub fn main() void {
|
||||
<tr>
|
||||
<th scope="row">{#syntax#}void{#endsyntax#}</th>
|
||||
<td>(none)</td>
|
||||
<td>0 bit type</td>
|
||||
<td>Always the value {#syntax#}void{}{#endsyntax#}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{#syntax#}noreturn{#endsyntax#}</th>
|
||||
@ -1061,7 +1061,7 @@ fn addOne(number: i32) i32 {
|
||||
<p>
|
||||
Test declarations contain the {#link|keyword|Keyword Reference#} {#syntax#}test{#endsyntax#}, followed by an
|
||||
optional name written as a {#link|string literal|String Literals and Unicode Code Point Literals#}, followed
|
||||
by a {#link|block|blocks#} containing any valid Zig code that is allowed in a {#link|function|Functions#}.
|
||||
by a {#link|block|Blocks#} containing any valid Zig code that is allowed in a {#link|function|Functions#}.
|
||||
</p>
|
||||
<aside>
|
||||
By convention, non-named tests should only be used to {#link|make other tests run|Nested Container Tests#}.
|
||||
@ -4024,7 +4024,7 @@ test "call foo" {
|
||||
{#code_end#}
|
||||
{#header_close#}
|
||||
|
||||
{#header_open|blocks#}
|
||||
{#header_open|Blocks#}
|
||||
<p>
|
||||
Blocks are used to limit the scope of variable declarations:
|
||||
</p>
|
||||
@ -4088,6 +4088,22 @@ test "separate scopes" {
|
||||
}
|
||||
{#code_end#}
|
||||
{#header_close#}
|
||||
|
||||
{#header_open|Empty Blocks#}
|
||||
<p>An empty block is equivalent to {#syntax#}void{}{#endsyntax#}:</p>
|
||||
{#code_begin|test|empty_block#}
|
||||
const std = @import("std");
|
||||
const expect = std.testing.expect;
|
||||
|
||||
test {
|
||||
const a = {};
|
||||
const b = void{};
|
||||
try expect(@TypeOf(a) == void);
|
||||
try expect(@TypeOf(b) == void);
|
||||
try expect(a == b);
|
||||
}
|
||||
{#code_end#}
|
||||
{#header_close#}
|
||||
{#header_close#}
|
||||
|
||||
{#header_open|switch#}
|
||||
@ -11987,7 +12003,7 @@ fn readU32Be() u32 {}
|
||||
{#syntax#}break{#endsyntax#} can be used with a block label to return a value from the block.
|
||||
It can also be used to exit a loop before iteration completes naturally.
|
||||
<ul>
|
||||
<li>See also {#link|blocks#}, {#link|while#}, {#link|for#}</li>
|
||||
<li>See also {#link|Blocks#}, {#link|while#}, {#link|for#}</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user