If behavior
Monkey Forums/Monkey Bug Reports/If behavior
| ||
I'm using this code:If (False) If (True) Print "test 1" If (True) If (True) Print "test 2" Print "one" Print "two" I'm expecting to see "test2, one, two", but instead I see just "two". Easy fixable by placing End If's in there, but I found it confusing behavior. The double If is something I use mainly if the second condition contains an object that needs to be verified before usage, such as this: if (selection <> null) if (selection.parent = currentItem) selection.display(); I'm using MacOS, HTML5 and the Monkey 'Love' edition (version 69) |
| ||
In the languages monkey outputs to, if the first expression fails they don't evaluate the latter expression. So If blah <> Null And blah.blah = "something" Print "blah" Will not crash your game if blah is null. |
| ||
Maybe it is just a habit, coming from Blitz3D. Still, the above is a bug, right? |
| ||
I'm not entirely sure if it's a bug or 'by design'. Will have to wait for Mark to chime in on this one. |
| ||
Weirdly, Monkey appears to be appending the 2nd If line to the first - try inserting a newline between the 2. Will have a look at this. Using 'And' fixes it too. |
| ||
What language are you using that doesn't support short-circuited boolean expressions? o_O |
| ||
It is not the language, it is me. It is a very very old habit, that I've never updated over the years. |