FirstTimeDebugging - compile warning

Dear community,

I'm reading "Develop in Swift Fundamentals", and on page 89 it asks us to open a file from the downloaded file (page 9 - Download Student Materials link).

I was running the last part of the exercise of page 89 and it seems I got stuck when trying to remove the last compile warning message:

"1. Condition always evaluates to false"

"Will never be executed"

Please take a look at the screenshot, where you can see the whole code and context.

I have tried to add a few breakpoints (rows 10 to 12) in order to see if they would get ignored but it looks like it's still there.

Any idea how to remove / get rid of this compile warning message?

Thanks, Rodrigo

The following condition:

if false 

Will never be true so the code inside the if block

print("Will this line of code ever be reached")
someMethod()

Will never execute.

I have not read the book you are following. But it looks like the point of that code is to quiz you on whether the code in the if block will ever be reached, and not to build without any warnings.

If you want to remove the warning, provide a condition that could be true or false or remove the if statement and the braces. But I think removing the warning defeats the point of the exercise.

Thank you very much for your insight, @szymczyk.

Sorry, I should have shared the book page to give you a better context. If I understood it correctly on the bottom of the page, it expects us to address the warning issues.

Thank you again, Rodrigo

Removing the if block will remove the warning. But I do not know if that is what the book wants you to do. I am not sure what the code is supposed to do because I have not read the book.

Thanks @szymczyk ,

Once again, I appreciate your support. Have a great day.

FirstTimeDebugging - compile warning
 
 
Q