1 00:00:00,820 --> 00:00:05,560 OK, how did you find that it should be fairly straightforward and if you like me, you would have used 2 00:00:05,560 --> 00:00:10,450 that second example because it fits our homework requirement quite well. 3 00:00:10,990 --> 00:00:13,360 So first, we have a variable that my age equals 60. 4 00:00:14,340 --> 00:00:16,380 We're going to switch the major variable. 5 00:00:17,990 --> 00:00:24,320 Between zero and 30, we're going to say you're young, 30 and 60, you're middle aged and default is 6 00:00:24,320 --> 00:00:25,830 your old grandpa. 7 00:00:26,420 --> 00:00:28,400 It's a free press play we should have. 8 00:00:28,400 --> 00:00:30,080 You are old now. 9 00:00:30,440 --> 00:00:34,070 You may see 60 here and think, why isn't this printing? 10 00:00:35,080 --> 00:00:43,290 Well, that's because we have less than 60, so 60 actually falls into the default category. 11 00:00:44,280 --> 00:00:49,010 That's pretty straightforward is how it goes, if you're six, you are young. 12 00:00:51,150 --> 00:00:57,690 OK, I hope you got that, and if you want to read up about switch cases, then I'd advise you go to 13 00:00:58,020 --> 00:01:03,060 just search for swift coding language on Google and you'll come up to the official website that Apple 14 00:01:03,060 --> 00:01:05,550 produce that run you through all these examples. 15 00:01:05,550 --> 00:01:09,960 You'll see some of these examples there as well, because they were the best ones that I found, to 16 00:01:09,960 --> 00:01:10,410 be honest. 17 00:01:11,940 --> 00:01:17,670 OK, the final thing I want to say about which case, if we scroll up here is look how neat this is, 18 00:01:18,480 --> 00:01:18,830 right? 19 00:01:19,200 --> 00:01:22,740 I can see by one glance what all the cases are. 20 00:01:23,070 --> 00:01:28,280 If you juxtapose this to the ifs, I'll just copy it from my notes with the IFS. 21 00:01:31,470 --> 00:01:32,070 Here it is. 22 00:01:32,490 --> 00:01:35,100 So if we have the if else here. 23 00:01:40,050 --> 00:01:47,010 Now, this, if else, is only three sections, but because each section isn't the same length with 24 00:01:47,010 --> 00:01:52,950 these if statements and there are lots of different words floating around, that's not good for our 25 00:01:52,950 --> 00:01:55,530 weak human brains, that should be else. 26 00:01:56,190 --> 00:02:02,580 It's not good for our weak human brains in terms of understanding the pattern and flow as opposed to 27 00:02:02,730 --> 00:02:05,710 this, which is much, much more readable. 28 00:02:06,090 --> 00:02:12,750 So if I were you, I'd go with switch case wherever it makes sense as a preference over if else.