Both sides previous revision Previous revision Next revision | Previous revision | ||
hpl2:amnesia:script_language_reference_and_guide:control_flow_-_conditional_statements [2013/01/03 02:24] thegreatcthulhu |
hpl2:amnesia:script_language_reference_and_guide:control_flow_-_conditional_statements [2013/01/03 16:15] (current) thegreatcthulhu [Comparison Operators] |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Control Flow - Part1: Conditional Statements ====== | ====== Control Flow - Part1: Conditional Statements ====== | ||
- | |||
- | ===== At a Glance ===== | ||
---- | ---- | ||
+ | |||
+ | ===== At a Glance ===== | ||
==== The If-Statement === | ==== The If-Statement === | ||
Line 270: | Line 270: | ||
Comparison operators are the usual mathematical operators you're familiar with. The result of their application is a ''bool'' (e.g. a < b is either ''true'' of ''false''). This is why they can be used in if-statement and loop conditions. This also means that their result can be assigned to ''bool'' variables, like this:\\ | Comparison operators are the usual mathematical operators you're familiar with. The result of their application is a ''bool'' (e.g. a < b is either ''true'' of ''false''). This is why they can be used in if-statement and loop conditions. This also means that their result can be assigned to ''bool'' variables, like this:\\ | ||
- | ''bool allItemsFound = ( foundItems == totalItems ); %%//%% after this, allItemsFound will be either true or false'' | + | <code c++>bool allItemsFound = ( foundItems == totalItems ); // allItemsFound will be either true or false</code> |
- | //Important:// Note that the comparison operator ''=='' (used to compare two values for equality) is //different// from the //assignment operator// ''='' (which is used to assign values to variables). //Don't use the assignment operator// when checking for equality in your conditions - this is a common source of error. Always double check to make sure you typed in ''==''. | + | <note important>//Important:// Note that the comparison operator ''=='' (used to compare two values for equality) is //different// from the //assignment operator// ''='' (which is used to assign values to variables). //Don't use the assignment operator// when checking for equality in your conditions - this is a common source of error. Always double check to make sure you typed in ''==''.</note> |
==== Using Logical Operators ==== | ==== Using Logical Operators ==== |