What that means is let's say we create a couple of variables, variable a, set it equal to 5, variable b, set it equal to 10, using the single equals sign to assign to set the values of these variables. A little later on in the code, I might write an if statement, and I'm asking, is a = b? But I accidentally used the single equals sign instead of the double equals sign. Well, we have a problem now. What's going to happen is we're going to execute the if statement. It's going to hit that code and it will say, "Okay, single equals sign, that's assignment" and it will set a equal to the value b. This successful operation will then be regarded as true and the code inside the if statement block will always be executed, even when you think it shouldn't be.
So to round those up, we have if (a == b), using the double equals sign, or not equal to, using the != sign. We have the strict equality, not just equal but identical. Similarly, we have the not strictly equal, the !==. All of this you are going to run into a lot. But we also have the other kinds of comparison. If a>b. Again, remember it doesn't really care what any of these values are.
Whatever is in the parentheses just needs to be true or false. a is either greater than b or it is not. a is either less than b or it is not. We also have the >= and not surprisingly, the <=. All of these operators, if there is more than one character in them, you can't put a space in between them. They are all considered one indivisible unit. What we often then have to do is take it a step further. We need to ask multiple things at the same time.
So let's say I've got four variables. What I want to ask is if the variable a is equal to the variable b and the variable c is equal to the variable d? Now, I could do this with two if statements but it's nice to combine them all on one condition. I can't use the word and here. There are some languages where you do. Things like the Basic based languages but not in the C-based languages. What we use instead is the double ampersand. Now what this means is both of these conditions, a has to be equal to b or strictly equal to b and c has to be strictly equal to d, for this whole thing to be regarded as true.
Again, the entire contents of the parentheses have to be true. And sometimes we don't want to go that far. We might ask if a is strictly equal to b or c is strictly equal to d, then we want that condition to be true. Well, instead of the two ampersands, we use the two vertical bars, pipe symbols depending on what you call them, are how we say an Or inside this condition. To make it a bit clearer to read, you often enclose the separate conditions inside their own set of parentheses.
You don't have to do this, but it can make it a bit more readable. So in this case, we're saying if a > b and c < d. And sometimes when you have these complex conditions with longer named variables, they can get pretty long so you can break them onto multiple lines. Although keep each unit together. I wouldn't typically take it this far, but because line breaks are insignificant, we could do it if we thought it made it more readable.
Finally, the course compares how code is written in several different languages, the libraries and frameworks that have grown around them, and the reasons to choose each one.
- Writing source code
- Understanding compiled and interpreted languages
- Requesting input
- Working with numbers, characters, strings, and operators
- Writing conditional code
- Making the code modular
- Writing loops
- Finding patterns in strings
- Working with arrays and collections
- Adopting a programming style
- Reading and writing to various locations
- Managing memory usage
- Learning about other languages