authorgravatar for hcnelson99@gmail.comHenry Nelson <hcnelson99@gmail.com> 2018-12-10 00:50:12-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-12-11 01:42:54-05:00
log68b0fce62f684a4b491ebb36dea06bd4d9ff5219
treea9c8ad41014945e07e354e0075b03df15233fb94
parent1b0f4d59763e273901717199e47764745aed2631

Document explicitly ignoring expression values


1 files changed, 12 insertions(+), 4 deletions(-)

doc/langref.html.in+12-4
......@@ -4264,13 +4264,21 @@ fn foo() i32 {
42644264 return 1234;
42654265}
42664266 {#code_end#}
4267 <p>However, if the expression has type {#syntax#}void{#endsyntax#}:</p>
4267 <p>However, if the expression has type {#syntax#}void{#endsyntax#}, there will be no error. Function return values can also be explicitly ignored by assigning them to {#syntax#}_{#endsyntax#}. </p>
42684268 {#code_begin|test#}
4269test "ignoring expression value" {
4270 foo();
4269test "void is ignored" {
4270 returnsVoid();
4271}
4272
4273test "explicitly ignoring expression value" {
4274 _ = foo();
42714275}
42724276
4273fn foo() void {}
4277fn returnsVoid() void {}
4278
4279fn foo() i32 {
4280 return 1234;
4281}
42744282 {#code_end#}
42754283 {#header_close#}
42764284