0 added
0 removed
Original
2026-01-01
Modified
2026-03-09
1
<p>Muffin began working on another program “Can I start the project?”. And we will test it and fix the errors, if necessary.</p>
1
<p>Muffin began working on another program “Can I start the project?”. And we will test it and fix the errors, if necessary.</p>
2
<p>The program reviews several conditions and gives an expert opinion. First, it checks to see if any of the developers are on vacation. We need to test this condition for different types of data.</p>
2
<p>The program reviews several conditions and gives an expert opinion. First, it checks to see if any of the developers are on vacation. We need to test this condition for different types of data.</p>
3
<p>The fact of the matter is that we receive information on vacations from managers in completely different formats. Some immediately will say that the developers are still on vacation, that is, will give us true, and some will not understand the question and say how many developers are on vacation, that is, give us a number. And some will remain silent; if no one is on vacation, we will get an empty line.</p>
3
<p>The fact of the matter is that we receive information on vacations from managers in completely different formats. Some immediately will say that the developers are still on vacation, that is, will give us true, and some will not understand the question and say how many developers are on vacation, that is, give us a number. And some will remain silent; if no one is on vacation, we will get an empty line.</p>
4
<p>Here the comparison of values does not help us, because the data can come in any form. Since in the condition block all values are converted to a logical type, we can use any values as conditions: numbers, strings, true and false, variables that contain such data.</p>
4
<p>Here the comparison of values does not help us, because the data can come in any form. Since in the condition block all values are converted to a logical type, we can use any values as conditions: numbers, strings, true and false, variables that contain such data.</p>
5
<p>The main thing is to understand how these values are cast to a logical type. If true and false remain themselves, numbers and strings are cast in a special way. For example, all numbers except 0 are true, and 0 is false. All lines except the empty string are true, empty string '' is false. You can say that values that do not seem to contain anything (like 0 or empty string ''), are cast to false, and all the others are cast to true.</p>
5
<p>The main thing is to understand how these values are cast to a logical type. If true and false remain themselves, numbers and strings are cast in a special way. For example, all numbers except 0 are true, and 0 is false. All lines except the empty string are true, empty string '' is false. You can say that values that do not seem to contain anything (like 0 or empty string ''), are cast to false, and all the others are cast to true.</p>
6
if ('some line') { // Non-empty string cast to true // Condition will be met }; if ('') { // Empty string cast to false // Condition will not be met }; if (123) { // Number is cast to true // Condition will be met }; if (0) { // 0 is cast to false // Condition will not be met };<p>Now we can return to the new Muffin’s program “Can I start the project?”. To verify that the condition is working correctly, we will try to change the value of the onVacation variable.</p>
6
if ('some line') { // Non-empty string cast to true // Condition will be met }; if ('') { // Empty string cast to false // Condition will not be met }; if (123) { // Number is cast to true // Condition will be met }; if (0) { // 0 is cast to false // Condition will not be met };<p>Now we can return to the new Muffin’s program “Can I start the project?”. To verify that the condition is working correctly, we will try to change the value of the onVacation variable.</p>