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













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!










share|improve this question













marked as duplicate by Martin R ios
Users with the  ios badge can single-handedly close ios questions as duplicates and reopen them as needed.

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 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















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!










share|improve this question













marked as duplicate by Martin R ios
Users with the  ios badge can single-handedly close ios questions as duplicates and reopen them as needed.

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 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













1












1








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!










share|improve this question















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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked yesterday









SaifSaif

1,2831923




1,2831923




marked as duplicate by Martin R ios
Users with the  ios badge can single-handedly close ios questions as duplicates and reopen them as needed.

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 ios
Users with the  ios badge can single-handedly close ios questions as duplicates and reopen them as needed.

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 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

















  • 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
















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












2 Answers
2






active

oldest

votes


















6














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")






share|improve this answer


















  • 3





    ... as explained in stackoverflow.com/q/48887696/1187415 :)

    – Martin R
    yesterday












  • @MartinR yeah, I failed to find this question :D

    – ManWithBear
    yesterday


















-4














enter image description heretry 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






share|improve this answer































    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    6














    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")






    share|improve this answer


















    • 3





      ... as explained in stackoverflow.com/q/48887696/1187415 :)

      – Martin R
      yesterday












    • @MartinR yeah, I failed to find this question :D

      – ManWithBear
      yesterday















    6














    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")






    share|improve this answer


















    • 3





      ... as explained in stackoverflow.com/q/48887696/1187415 :)

      – Martin R
      yesterday












    • @MartinR yeah, I failed to find this question :D

      – ManWithBear
      yesterday













    6












    6








    6







    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")






    share|improve this answer













    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")







    share|improve this answer












    share|improve this answer



    share|improve this answer










    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












    • 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













    -4














    enter image description heretry 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






    share|improve this answer





























      -4














      enter image description heretry 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






      share|improve this answer



























        -4












        -4








        -4







        enter image description heretry 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






        share|improve this answer















        enter image description heretry 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







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited yesterday

























        answered yesterday









        Sanad BarjawiSanad Barjawi

        10711




        10711













            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript