From 6c3ccea29b2034654558a0b8e839a4a5ee84c57f Mon Sep 17 00:00:00 2001 From: MateuszOkulus Date: Sat, 28 Dec 2019 16:59:47 +0100 Subject: [PATCH] Make it more obvious that ifs are expressions --- doc/langref.html.in | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/doc/langref.html.in b/doc/langref.html.in index 5894810555..a1094ab650 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -3714,6 +3714,14 @@ fn typeNameLength(comptime T: type) usize { const assert = @import("std").debug.assert; +test "if expression" { + // If expressions are used instead of a ternary expression. + const a: u32 = 5; + const b: u32 = 4; + const result = if (a != b) 47 else 3089; + assert(result == 47); +} + test "if boolean" { // If expressions test boolean conditions. const a: u32 = 5; @@ -3725,10 +3733,6 @@ test "if boolean" { } else { unreachable; } - - // If expressions are used instead of a ternary expression. - const result = if (a != b) 47 else 3089; - assert(result == 47); } test "if optional" {