From 8dff6b790526a189ceccad834f061b62d02a6863 Mon Sep 17 00:00:00 2001 From: Uzair Khan <56188800+uxrkhan@users.noreply.github.com> Date: Fri, 7 Aug 2020 18:02:38 +0530 Subject: [PATCH 1/2] Corrected switch case logic --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 481ab84..fbe4cdd 100644 --- a/README.md +++ b/README.md @@ -118,8 +118,8 @@ for (x : y) a; // Range-based for loop e.g. do a; while (x); // Equivalent to: a; while(x) a; switch (x) { // x must be int - case X1: a; // If x == X1 (must be a const), jump here - case X2: b; // Else if x == X2, jump here + case X1: a; break; // If x == X1 (must be a const), jump here + case X2: b; break; // Else if x == X2, jump here default: c; // Else jump here (optional) } break; // Jump out of while, do, or for loop, or switch From 4d3466a7bac97910fac88f3e3fbb320466044b62 Mon Sep 17 00:00:00 2001 From: Uzair Khan <56188800+uxrkhan@users.noreply.github.com> Date: Fri, 7 Aug 2020 18:05:01 +0530 Subject: [PATCH 2/2] Corrected switch case logic --- cheatsheet-as-sourcefile.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cheatsheet-as-sourcefile.cpp b/cheatsheet-as-sourcefile.cpp index 0d3dedd..3ea4f33 100644 --- a/cheatsheet-as-sourcefile.cpp +++ b/cheatsheet-as-sourcefile.cpp @@ -116,8 +116,8 @@ for (x : y) a; // Range-based for loop e.g. do a; while (x); // Equivalent to: a; while(x) a; switch (x) { // x must be int -case X1: a; // If x == X1 (must be a const), jump here -case X2: b; // Else if x == X2, jump here +case X1: a; break; // If x == X1 (must be a const), jump here +case X2: b; break; // Else if x == X2, jump here default: c; // Else jump here (optional) } break; // Jump out of while, do, or for loop, or switch