Xcode 10.1 “return” statement doesn't stop function execution [duplicate]early return from a void-func in Swift?Xcode 4 Error: Error Starting ExecutableXcode doesn't show code when stops at breakpointsUIScrollView Scrollable Content Size AmbiguitySwift Beta performance: sorting arraysSwift Parse - Method doesn't stop executingThe amount of Xcode tasks increase after every buildAdding localizable strings on xcode 10.1lldb-rpc-server in Xcode Version is 10.1?What's the solution for “error: Couldn't IRGen expression, no additional error” on Xcode 10.1?cloudkit disabled in capabilities after upgrade to xcode 10.1
How could a planet have erratic days?
Limits and Infinite Integration by Parts
15% tax on $7.5k earnings. Is that right?
A social experiment. What is the worst that can happen?
What is the highest possible scrabble score for placing a single tile
The probability of Bus A arriving before Bus B
Moving brute-force search to FPGA
How do you make your own symbol when Detexify fails?
Electoral considerations aside, what are potential benefits, for the US, of policy changes proposed by the tweet recognizing Golan annexation?
Do the primes contain an infinite almost arithmetic progression?
Can a Canadian Travel to the USA twice, less than 180 days each time?
Does an advisor owe his/her student anything? Will an advisor keep a PhD student only out of pity?
How can I write humor as character trait?
Sums of entire surjective functions
Hero deduces identity of a killer
Can the US President recognize Israel’s sovereignty over the Golan Heights for the USA or does that need an act of Congress?
Can I say "fingers" when referring to toes?
Calculating total slots
Is there a way to get `mathscr' with lower case letters in pdfLaTeX?
On a tidally locked planet, would time be quantized?
Terse Method to Swap Lowest for Highest?
How to hide some fields of struct in C?
What should you do if you miss a job interview (deliberately)?
Keeping a ball lost forever
Xcode 10.1 “return” statement doesn't stop function execution [duplicate]
early return from a void-func in Swift?Xcode 4 Error: Error Starting ExecutableXcode doesn't show code when stops at breakpointsUIScrollView Scrollable Content Size AmbiguitySwift Beta performance: sorting arraysSwift Parse - Method doesn't stop executingThe amount of Xcode tasks increase after every buildAdding localizable strings on xcode 10.1lldb-rpc-server in Xcode Version is 10.1?What's the solution for “error: Couldn't IRGen expression, no additional error” on Xcode 10.1?cloudkit disabled in capabilities after upgrade to xcode 10.1
This question already has an answer here:
early return from a void-func in Swift?
5 answers
The return
statement in Xcode 10.1 is not honoured by debugger,
For eg.,
func doSomething()
print("Task A")
return
print("Task B")
This prints
Task A
Task B //This is not expected to be printed as we have a `return` before this line
Can someone help me!
ios swift xcode xcode10.1
marked as duplicate by Martin R
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
yesterday
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
early return from a void-func in Swift?
5 answers
The return
statement in Xcode 10.1 is not honoured by debugger,
For eg.,
func doSomething()
print("Task A")
return
print("Task B")
This prints
Task A
Task B //This is not expected to be printed as we have a `return` before this line
Can someone help me!
ios swift xcode xcode10.1
marked as duplicate by Martin R
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
yesterday
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
That should not happen. Try a clean and rebuild. Sometimes Xcode loses its mind and does not rebuild your source files after you make changes.
– Duncan C
yesterday
1
@DuncanC: It does happen (see the linked-to Q&A). Swift executes the statementreturn print("Task B")
, which prints the string and returns void. – Whether that should be considered a bug or not is a different story. Inserting a semicolon helps.
– Martin R
yesterday
@MartinR, well it's definitely not a bug, just a natural quirk of non-mandatory-semicolon syntax.
– user28434
yesterday
add a comment |
This question already has an answer here:
early return from a void-func in Swift?
5 answers
The return
statement in Xcode 10.1 is not honoured by debugger,
For eg.,
func doSomething()
print("Task A")
return
print("Task B")
This prints
Task A
Task B //This is not expected to be printed as we have a `return` before this line
Can someone help me!
ios swift xcode xcode10.1
This question already has an answer here:
early return from a void-func in Swift?
5 answers
The return
statement in Xcode 10.1 is not honoured by debugger,
For eg.,
func doSomething()
print("Task A")
return
print("Task B")
This prints
Task A
Task B //This is not expected to be printed as we have a `return` before this line
Can someone help me!
This question already has an answer here:
early return from a void-func in Swift?
5 answers
ios swift xcode xcode10.1
ios swift xcode xcode10.1
asked yesterday
SaifSaif
1,2831923
1,2831923
marked as duplicate by Martin R
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
yesterday
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Martin R
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
yesterday
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
That should not happen. Try a clean and rebuild. Sometimes Xcode loses its mind and does not rebuild your source files after you make changes.
– Duncan C
yesterday
1
@DuncanC: It does happen (see the linked-to Q&A). Swift executes the statementreturn print("Task B")
, which prints the string and returns void. – Whether that should be considered a bug or not is a different story. Inserting a semicolon helps.
– Martin R
yesterday
@MartinR, well it's definitely not a bug, just a natural quirk of non-mandatory-semicolon syntax.
– user28434
yesterday
add a comment |
That should not happen. Try a clean and rebuild. Sometimes Xcode loses its mind and does not rebuild your source files after you make changes.
– Duncan C
yesterday
1
@DuncanC: It does happen (see the linked-to Q&A). Swift executes the statementreturn print("Task B")
, which prints the string and returns void. – Whether that should be considered a bug or not is a different story. Inserting a semicolon helps.
– Martin R
yesterday
@MartinR, well it's definitely not a bug, just a natural quirk of non-mandatory-semicolon syntax.
– user28434
yesterday
That should not happen. Try a clean and rebuild. Sometimes Xcode loses its mind and does not rebuild your source files after you make changes.
– Duncan C
yesterday
That should not happen. Try a clean and rebuild. Sometimes Xcode loses its mind and does not rebuild your source files after you make changes.
– Duncan C
yesterday
1
1
@DuncanC: It does happen (see the linked-to Q&A). Swift executes the statement
return print("Task B")
, which prints the string and returns void. – Whether that should be considered a bug or not is a different story. Inserting a semicolon helps.– Martin R
yesterday
@DuncanC: It does happen (see the linked-to Q&A). Swift executes the statement
return print("Task B")
, which prints the string and returns void. – Whether that should be considered a bug or not is a different story. Inserting a semicolon helps.– Martin R
yesterday
@MartinR, well it's definitely not a bug, just a natural quirk of non-mandatory-semicolon syntax.
– user28434
yesterday
@MartinR, well it's definitely not a bug, just a natural quirk of non-mandatory-semicolon syntax.
– user28434
yesterday
add a comment |
2 Answers
2
active
oldest
votes
Because expression after return
is treated as argument of return
.
So your code understood by compiler as:
func doSomething()
print("Task A")
return print("Task B")
To prevent it you can use semicolon to explicitly separate this expressions.
Like that:
func doSomething()
print("Task A")
return;
print("Task B")
3
... as explained in stackoverflow.com/q/48887696/1187415 :)
– Martin R
yesterday
@MartinR yeah, I failed to find this question :D
– ManWithBear
yesterday
add a comment |
try this :
func doSomething()
return print("Task A")
print("Task B")
the function itself does not wait for a value to get return, thats why in your case return wont stop the execution of the function,
but if your implement the return the way i showed above, it will return the print("task a") and will stop right away
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Because expression after return
is treated as argument of return
.
So your code understood by compiler as:
func doSomething()
print("Task A")
return print("Task B")
To prevent it you can use semicolon to explicitly separate this expressions.
Like that:
func doSomething()
print("Task A")
return;
print("Task B")
3
... as explained in stackoverflow.com/q/48887696/1187415 :)
– Martin R
yesterday
@MartinR yeah, I failed to find this question :D
– ManWithBear
yesterday
add a comment |
Because expression after return
is treated as argument of return
.
So your code understood by compiler as:
func doSomething()
print("Task A")
return print("Task B")
To prevent it you can use semicolon to explicitly separate this expressions.
Like that:
func doSomething()
print("Task A")
return;
print("Task B")
3
... as explained in stackoverflow.com/q/48887696/1187415 :)
– Martin R
yesterday
@MartinR yeah, I failed to find this question :D
– ManWithBear
yesterday
add a comment |
Because expression after return
is treated as argument of return
.
So your code understood by compiler as:
func doSomething()
print("Task A")
return print("Task B")
To prevent it you can use semicolon to explicitly separate this expressions.
Like that:
func doSomething()
print("Task A")
return;
print("Task B")
Because expression after return
is treated as argument of return
.
So your code understood by compiler as:
func doSomething()
print("Task A")
return print("Task B")
To prevent it you can use semicolon to explicitly separate this expressions.
Like that:
func doSomething()
print("Task A")
return;
print("Task B")
answered yesterday
ManWithBearManWithBear
684519
684519
3
... as explained in stackoverflow.com/q/48887696/1187415 :)
– Martin R
yesterday
@MartinR yeah, I failed to find this question :D
– ManWithBear
yesterday
add a comment |
3
... as explained in stackoverflow.com/q/48887696/1187415 :)
– Martin R
yesterday
@MartinR yeah, I failed to find this question :D
– ManWithBear
yesterday
3
3
... as explained in stackoverflow.com/q/48887696/1187415 :)
– Martin R
yesterday
... as explained in stackoverflow.com/q/48887696/1187415 :)
– Martin R
yesterday
@MartinR yeah, I failed to find this question :D
– ManWithBear
yesterday
@MartinR yeah, I failed to find this question :D
– ManWithBear
yesterday
add a comment |
try this :
func doSomething()
return print("Task A")
print("Task B")
the function itself does not wait for a value to get return, thats why in your case return wont stop the execution of the function,
but if your implement the return the way i showed above, it will return the print("task a") and will stop right away
add a comment |
try this :
func doSomething()
return print("Task A")
print("Task B")
the function itself does not wait for a value to get return, thats why in your case return wont stop the execution of the function,
but if your implement the return the way i showed above, it will return the print("task a") and will stop right away
add a comment |
try this :
func doSomething()
return print("Task A")
print("Task B")
the function itself does not wait for a value to get return, thats why in your case return wont stop the execution of the function,
but if your implement the return the way i showed above, it will return the print("task a") and will stop right away
try this :
func doSomething()
return print("Task A")
print("Task B")
the function itself does not wait for a value to get return, thats why in your case return wont stop the execution of the function,
but if your implement the return the way i showed above, it will return the print("task a") and will stop right away
edited yesterday
answered yesterday
Sanad BarjawiSanad Barjawi
10711
10711
add a comment |
add a comment |
That should not happen. Try a clean and rebuild. Sometimes Xcode loses its mind and does not rebuild your source files after you make changes.
– Duncan C
yesterday
1
@DuncanC: It does happen (see the linked-to Q&A). Swift executes the statement
return print("Task B")
, which prints the string and returns void. – Whether that should be considered a bug or not is a different story. Inserting a semicolon helps.– Martin R
yesterday
@MartinR, well it's definitely not a bug, just a natural quirk of non-mandatory-semicolon syntax.
– user28434
yesterday