[Swift] Going through Apple’s introductory course on Swift, I don’t understand this if/else problem via /r/learnprogramming


[Swift] Going through Apple’s introductory course on Swift, I don’t understand this if/else problem

I've attached screenshots of the problem in question: http://ift.tt/2v9XqM2

It seems to me that, given numbers == 100, the if statement should return a true to numbers > 99, and so it should print "What a smallish number", then skip the else statement because the initial statement returned a true, and be left with only the "Goodbye."

So it should print "What a smallish number. Goodbye."

The ebook is telling me that's wrong, and it seems that for some reason the initial if is returned as a false, and that it's then moving on to the else if which is of course returning a true, so that the final printout reads "That's not so big. Goodbye."

I don't understand why this is.

Submitted July 11, 2017 at 03:35PM by socialistvegan
via reddit http://ift.tt/2tKKr3y

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s