gooberboobbutt gooberboobbutt - 1 year ago 60
Swift Question

If you have "return" in brackets, will following code outside of the bracket not be executed?

Here is the code in question.

if let error = error {


So if error != nil and it lets error = error, it will print to the console and return, so it will not run userSetDisplayName. Otherwise if error == nil, it doesnt print and it does not return and it will run userSetDisplayName. Is this the case?

Answer Source

Yes. Any return statement will end the current subprogram.

Also: This is not a bracket: {, it's a curly brace, or just braces

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download