Learn to Code via Tutorials on Repl.it!

← Back to all posts
Golang Googles C++ Part 3: Logic Operations!
JustAWalrus (1187)

First lemme say that we are falling down in the ranks so I need your support more now than ever.

Secondly, go check out @HahaYes and his C++ tutorial.

Okay now we can get to work!

So let’s say you had a variable and you wanted to test what its value was.

Well, you can’t.

Unless you have logic operations!

Logic is a fundamental of computer science and for good reason too!

Without logic a computer is just a remembering machine. Not very useful.

But you can introduce logic very easily.

In Go logic is easy:

if <condition> == <value> {

For example:

if 5 + 5 == 10 {

See it’s very simple!

Now we need to also talk about else if and else statements!

Else if - executes if the prior if and or else if statements weren’t true but this one is.
Else - executes if the prior if and else if statements weren’t true

For example:

if 5 == 5 {
    x := 5
} else if 5 == 4 {
    x := 4
} else {

Yep that’s it!

Now what are operators?

Well in math operators are like +, -, *, /, and =

What is one thing they all have in common?

They take two values and perform operations with them.

These two values otherwise known as operands can include operators too!

Well in Go these can apply to if statements too!

So here they are.


&& - executes the code only if both conditions on either side are true.
|| - executes the code only if one or more of the conditions on either side are true.
== - equals sign
! - does not equal sign


Make a trivia game comment a link to yours down below!

Anyway Upvote for part 4!

Part 4: https://repl.it/talk/learn/Golang-Googles-C-Part-4-Functions/42944

Part 5: https://repl.it/talk/learn/Golang-Googles-C-Part-5-For-Loops/43033

awesome10 (231)

ooh smart no days so that you can post every 2 hours and @hahayes has to post at most once a day

HahaYes (1862)

thanks for the shoutout! Yours will be in the next series.