bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/Go/Go Tutorial
Go•Go Tutorial

Go Conditions

Flash cards

Review the key moves

1/3
Core idea

What is the main idea behind Go Conditions?

Lesson checks

Practice each idea before moving on

Short Mimo-style checks built from this lesson's code, terms, and sequence.

1Quick choice

Which statement best captures the main point of this lesson?

2Order

Put the learning moves in the order that makes the concept easiest to apply.

Go supports the usual comparison operators from mathematics:
A condition can be either true or false .
Conditional statements are used to perform different actions based on different conditions.

Conditional statements are used to perform different actions based on different conditions.

Go Conditions

A condition can be either true or false .

Go supports the usual comparison operators from mathematics:

  • Less than <
  • Less than or equal <=
  • Greater than >
  • Greater than or equal >=
  • Equal to ==
  • Not equal to !=

Additionally, Go supports the usual logical operators :

  • Logical AND &&
  • Logical OR ||
  • Logical NOT !

You can use these operators or their combinations to create conditions for different decisions.

Example
x > y
x != y
(x > y) && (y > z)
(x == y)z

Go has the following conditional statements

  • Use if to specify a block of code to be executed, if a specified condition is true
  • Use else to specify a block of code to be executed, if the same condition is false
  • Use else if to specify a new condition to test, if the first condition is false
  • Use switch to specify many alternative blocks of code to be executed

Previous

Go Bitwise Operators

Next

Go if statement