Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions examples/stage0/snippets/Conditionals.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
boolean condition_A;
boolean condition_B;
boolean conditionA;
boolean conditionB;
boolean condition;

class Drivetrain {
Expand Down Expand Up @@ -33,10 +33,10 @@ void main() {
// [/ifExample]

// [elseIfSyntax]
if (condition_A) {
// code to run when condition_A is true
} else if (condition_B) {
// code to run when Condition_B is true
if (conditionA) {
// code to run when conditionA is true
} else if (conditionB) {
// code to run when ConditionB is true
}
// [/elseIfSyntax]

Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions src/content/docs/learning-course/stage0/conditionals.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,14 @@ The syntax is similar to an `if` statement but now it has `else if` at the end.
Let's break down what this new addition means.
`else if` is a keyword that allows the conditional to run a different task if the if statement is false.

If `condition_A` is true then the code inside the `if` block will run.
If `condition_A` if false, then it will go to the `else if` statement.
If `condition_B` is true, the code inside the `else if` block will run.
If `condition_B` if false, then it will exit the statement and none of the code will run.
If `conditionA` is true then the code inside the `if` block will run.
If `conditionA` if false, then it will go to the `else if` statement.
If `conditionB` is true, the code inside the `else if` block will run.
If `conditionB` if false, then it will exit the statement and none of the code will run.
This is also described in the flowchart below

<ContentFigure
src="/learning-course/stage0/conditionals/elseif.png"
src="/learning-course/stage0/conditionals/elseif.webp"
width="700px"
height="800px"
/>
Expand Down