0
Could somebody explain boolean value more clearly?
the definition in the module is confusing and I can't picture it in the example given in the module. what does it actually do?
3 Answers
+ 3
There are two boolean values: true and false. As well as the two keywords, statements have a value that is one of these two. For example, 5>2 is true, 3<3 is false, 1==1 is true. You often use these conditions with variables to make code execute if some given conditions are true - all if statements are of the form if (boolean) and the code is executed if boolean resolves to true.
How might you allow a user to login to an application? you could say if(userId == "dan" && password == 12345) {code}
so the code will only run if the bit before && has a boolean value of true AND the bit after && is true. If either condition is false the if statement will not execute. This is due to the meaning of the boolean operator &&.
+ 1
ohhkay thanks man! really appreciate it!
- 1
Boolean mean True or False