Coding at Home: April 16th

UPDATE!!

Due to unforeseen circumstances, we weren’t able to live stream the coding session today.

We will be live tomorrow (Friday, April 17th) with bells on*.

*Warning, no actual bells will be worn.

We’re live at 1pm today, catch us on Twitch!

Logical Operators Return!

As with many of our sessions lately, yesterday’s was meaty. Logical operators are a whole new level in our programming toolbox.

We have the NOT operator, which is an exclamation mark (!) in front of a boolean variable, like !isOnGem. So if we are on a gem, that whole statement, the exclamation mark and all, will return false. Confusing? Sure, maybe a little. But we’ll get it with practice.

Then there’s the AND operator, which is two ampersands together (&&). This tests to see if both values are true. If one of them is false, the test will fail and return false. In code, it would look something like this: isOnGem && isBlocked. The only way this returns true is if we are on a gem and we’re also unable to move forward (that’s what the isBlocked tests).

Lastly, there’s the OR operator, which is two pipes next to each other (||). In this case, if one of the values is true, we’ll return true. The code looks like this: isOnGem || isBlocked. In this case, if either case is true… if we’re on a gem or we’re unable to move forward… or even both are true, we’ll return true.

Deep Breaths

The puzzles will require a bit of patience and sometimes a bit of trial and error to get a feel for combining conditions. But that’s what we’ll be practicing today.

Hopefully a few of the tricks we use to visualize the concept of logical operators will help you in today’s session!

See you at 1pm!

One thought on “Coding at Home: April 16th”

Leave a Reply

Your email address will not be published. Required fields are marked *