| Blockland Forums > Modification Help |
| | and & vs || and &&? |
| (1/5) > >> |
| phflack:
i've noticed that most people use || and && in their code, but | and & work just the same is this a coding habit from other languages or are they different in some way? |
| ThinkInvisible:
I think it's because == is the normal equals command while = tests if one thing CAN equal another, so it seems to be common sense. |
| phflack:
== is actualy equals, while = is set, i don't think a single = tests anything |
| ThinkInvisible:
--- Quote from: phflack on March 11, 2012, 10:29:29 AM ---== is actualy equals, while = is set, i don't think a single = tests anything --- End quote --- Yes, it does. Ex. containerRadiusSearches: --- Code: ---while(%storage = containerSearchNext) --- End code --- While there are objects that can be found by the search, while loop is true. --- Code: ---%a = 0; while(%a = 1) %a += 1; --- End code --- infinite loop - and actually runs, because %a can be set to 1 |
| phflack:
--- Quote from: ThinkInvisible on March 11, 2012, 10:34:37 AM ---Yes, it does. Ex. containerRadiusSearches: --- Code: ---while(%storage = containerSearchNext) --- End code --- While there are objects that can be found by the search, while loop is true. --- Code: ---%a = 0; while(%a = 1) %a += 1; --- End code --- infinite loop - and actually runs, because %a can be set to 1 --- End quote --- actualy, X = Y returns Y overall so... $a = 0; $b = 1; $a = $b = 2; would set everything to 2 in your while loop example, it's returning 1 which is true, and forms the infinite loop edit: and echo($a = "hi"); echos hi |
| Navigation |
| Message Index |
| Next page |