Questions tagged [function-exit]
10 questions
70
votes
23 answers
Why is "else" rarely used after "if x then return"?
This method:
boolean containsSmiley(String s) {
if (s == null) {
return false;
}
else {
return s.contains(":)");
}
}
can equivalently be written:
boolean containsSmiley(String s) {
if (s == null) {
return…

Todd Owen
- 15,650
- 7
- 54
- 52
12
votes
23 answers
What to put in the IF block and what to put in the ELSE block?
This is a minor style question, but every bit of readability you add to your code counts.
So if you've got:
if (condition) then
{
// do stuff
}
else
{
// do other stuff
}
How do you decide if it's better like that, or like this:
if…

WW.
- 23,793
- 13
- 94
- 121
6
votes
1 answer
Inno Setup "return" like command/construct in Code
Is there any command/construct like return in C that exits immediately from a function of Inno Setup script code keeping the result code?
I would like something
If k = false then
Begin
Result:=false;
Exit;
End;

Maverick
- 1,105
- 12
- 41
4
votes
1 answer
Popup when leaving website
I got a problem with JavaScript.
I want a script that will pop-up on exit whole web-site a message with question and if visitor answers "NO" web page closes and if he answers "YES" he will be redirected to another page. I found a example at…

Daniil T.
- 1,145
- 2
- 13
- 33
3
votes
4 answers
C++ - How to execute a command on application exit?
I am very new to C++ and have recently started a project for which I need to access a device, collect certain data and forward it to a datastream on a local network.
While my application does all the things require it lacks on function: When I close…

Jonidas
- 187
- 4
- 21
3
votes
6 answers
Javascript: Trigger action on function exit
Is there a way to listen for a javascript function to exit? A trigger that could be setup when a function has completed?
I am attempting to use a user interface obfuscation technique (BlockUI) while an AJAX object is retrieving data from the DB, but…

Michael Runyon
- 1,209
- 1
- 13
- 13
2
votes
2 answers
Understanding the MSDN _beginthreadex function example
There's this function on _beginthreadex MSDN page:
unsigned __stdcall SecondThreadFunc( void* pArguments )
{
printf( "In second thread...\n" );
while ( Counter < 1000000 )
Counter++;
_endthreadex( 0 );
return 0;
}
I know you…

c00get
- 23
- 3
1
vote
6 answers
Quick question about returning from a nested statement
If I have something like a loop or a set of if/else statements, and I want to return a value from within the nest (see below), is the best way of doing this to assign the value to a field or property and return that?
See below:
bool b;
public bool…

GurdeepS
- 65,107
- 109
- 251
- 387
0
votes
1 answer
iPhone cocos2d [super onExit]; causing crash when touch event occurs.
Please help!
When I use:
-(void) onExit {
[super onExit];
}
my app crashes if the screen is touched in the next scene after onExit is called. The error points to:
-(void) touches:(NSSet*)touches withEvent:(UIEvent*)event withTouchType:(unsigned…

user1078461
- 35
- 4
0
votes
3 answers
WPF application OnExit event
I have a WPF application with a main Window.
In App.xaml.cs, in the OnExit event, I would like to use a method from my MainWindow code behind...
public partial class App
{
private MainWindow _mainWindow;
protected override void…

Gab
- 1,861
- 5
- 26
- 39