April 2017
Beginner to intermediate
394 pages
9h 16m
English
The next thing we need to consider is how we should do something based on what state we are in. When writing programs, conditional clauses such as the if and switch statements that we learned about earlier may make your code more difficult to manage. Sometimes, when writing code for specific functionality, writing if statements is completely understandable, especially if it makes sense when you are writing it. For example, the following code makes perfect sense:
void MinValue(int a, int b) { if (a < b) return a; else return b; } // Could also be written in the following way: void MinValue(int a, int b) { return (a < b) ? a : b; }
However, if you are writing something where you are checking what the type of ...
Read now
Unlock full access