OK, how did you find that it should be fairly straightforward and if you like me, you would have used
that second example because it fits our homework requirement quite well.
So first, we have a variable that my age equals 60.
We're going to switch the major variable.
Between zero and 30, we're going to say you're young, 30 and 60, you're middle aged and default is
your old grandpa.
It's a free press play we should have.
You are old now.
You may see 60 here and think, why isn't this printing?
Well, that's because we have less than 60, so 60 actually falls into the default category.
That's pretty straightforward is how it goes, if you're six, you are young.
OK, I hope you got that, and if you want to read up about switch cases, then I'd advise you go to
just search for swift coding language on Google and you'll come up to the official website that Apple
produce that run you through all these examples.
You'll see some of these examples there as well, because they were the best ones that I found, to
be honest.
OK, the final thing I want to say about which case, if we scroll up here is look how neat this is,
right?
I can see by one glance what all the cases are.
If you juxtapose this to the ifs, I'll just copy it from my notes with the IFS.
Here it is.
So if we have the if else here.
Now, this, if else, is only three sections, but because each section isn't the same length with
these if statements and there are lots of different words floating around, that's not good for our
weak human brains, that should be else.
It's not good for our weak human brains in terms of understanding the pattern and flow as opposed to
this, which is much, much more readable.
So if I were you, I'd go with switch case wherever it makes sense as a preference over if else.