Jump to content

Bohemia... haha makes me laugh


happydayz

Recommended Posts

i would have expected this to throw U & V tho....
 

Foo = {throw _this};
try {
if (true) then {"U" call Foo};
if (true) then {"V" call Foo};
throw "NOPE";
}catch{
systemChat format["Exception: %1",str _exception];
};
 because the opposite (false) will throw nope

I even tried something like this:

Foo = {throw _this;  
false  
};  
try {  
if (true) then {throw "U"};  
if (false) then {throw "V"};  
throw "NOPE";  }
catch{  
systemChat format["Exception: %1",str _exception];  
};
Link to comment
Share on other sites

Using round brackets always calls the code , at least in the try {}. Which is why I use braces.

I wouldn't have expected U and V as U is thrown to the exception and the code ends there. There is no Else statement.

Why do you want to return a false ?

Edit: Have found that false is never returned from foo, try replacing it with a hint. the throw must go straight to catch, as it is still in scope.

 

Edited by axeman
Link to comment
Share on other sites

tbh, a throw "U" will do the same. There is scope to do more in Foo so that something more descriptive could be returned as an Exception

Am sure there must be some performance to be gained with using a throw. It's the marriage of exitWith and Switch after a drunken week in Vegas.

Why not 'throw false' and handle the boolean in the catch statement ? 

Link to comment
Share on other sites

  • 3 weeks later...

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Discord

×
×
  • Create New...