authorgravatar for mateusz.okulus@protonmail.comMateuszOkulus <mateusz.okulus@protonmail.com> 2019-12-28 16:59:47+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-12-28 14:26:10-05:00
log6c3ccea29b2034654558a0b8e839a4a5ee84c57f
tree9fec9c754b35eb035e62ee83ab58fa89b96c8025
parent25e71216c4640a3d88c8f63912ea574ad6fa004c

Make it more obvious that ifs are expressions


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

doc/langref.html.in+8-4
......@@ -3714,6 +3714,14 @@ fn typeNameLength(comptime T: type) usize {
37143714
37153715const assert = @import("std").debug.assert;
37163716
3717test "if expression" {
3718 // If expressions are used instead of a ternary expression.
3719 const a: u32 = 5;
3720 const b: u32 = 4;
3721 const result = if (a != b) 47 else 3089;
3722 assert(result == 47);
3723}
3724
37173725test "if boolean" {
37183726 // If expressions test boolean conditions.
37193727 const a: u32 = 5;
......@@ -3725,10 +3733,6 @@ test "if boolean" {
37253733 } else {
37263734 unreachable;
37273735 }
3728
3729 // If expressions are used instead of a ternary expression.
3730 const result = if (a != b) 47 else 3089;
3731 assert(result == 47);
37323736}
37333737
37343738test "if optional" {