Earlier this month, you wrote your final mini-test of the year – focused on being able to explain how an array and a function work within a view model.
Depending on the sheet you received, you wrote one of three versions:
| Version | Colour of paper |
|---|---|
| A | Yellow |
| B | Pink |
| C | Blue |
Please use the navigation panel at right to review answers for the version of the mini-test that you wrote. ➡️
TIP
On the culminating task, you will be asked in your 6-minute interview to answer questions quite similar to the questions posed on this mini-test.
Your responses would be given based on the code that you will write for the culminating task.
It it worth your while to learn these concepts, if you did not do as well as you’d hoped on the mini-test.
If you demonstrate a strong understanding of these concepts during the culminating task interview, Mr. Gordon can apply his professional judgement and overlook a poor mini-test result.
Version A – Yellow
Question 1
Describe the overall purpose of the program.
SOLUTION
This program helps a user find recipes whose calorie counts match their dietary goals. The user adjusts two sliders — one for the minimum calories per serving and one for the maximum — and the app displays a filtered list of recipes whose calorie counts fall within that range, so the user can choose a recipe that fits the amount of food energy they are aiming for.
Question 2
Describe where input and output occur in the running of the program. Identify the specific line(s) of code responsible for each.
SOLUTION
Input occurs through two sliders. The minimum calories slider on line 118 binds to
viewModel.minCalories, and the maximum calories slider on line 131 binds toviewModel.maxCalories. Each time the user drags a slider, the bound property updates.Output occurs in several places. Lines 114 and 127 display the current slider values in the header. The
Liston line 156 outputs one row per matching recipe, showing the recipe’s name on line 158 and its calorie count on line 161. When no recipes match, theContentUnavailableViewon lines 149–153 is shown instead.
Question 3
Identify where data is first stored in an array. Reference the specific line(s) of code that accomplish this.
SOLUTION
Data is first stored in an array on line 27, where the
recipesproperty is declared and immediately initialized. TenRecipeinstances are created inline, beginning on line 28 with the entry for “Greek Salad” and ending on line 67 with the closing of the last entry for “Avocado Toast”.
Question 4
What is the name of the chosen array?
SOLUTION
recipes
Question 5
Describe where the chosen array is used in the program — for example, where it is iterated over, where individual elements are accessed, or where existing data in the array is used to produce new data or drive behaviour.
SOLUTION
The array is used in two main places. First, it is passed into
includeRecipesInRangeFrom(recipes:minCalories:maxCalories:)on line 142, where the function iterates over it on line 80 and accesses each element’scaloriesproperty on line 81 to decide whether to include the recipe in its returned result.Second, the filtered array returned by that call is stored in the local constant
matchingRecipeson line 141 and then driven through theListon line 156, which iterates over it to produce one row per matching recipe. Each row reads the element’snameon line 158 andcalorieson line 161.
Question 6
What does the data stored in the array represent within the program? Describe the type of data stored and what role it plays.
SOLUTION
Each element is an instance of the
Recipestruct (lines 9–16), representing one recipe. Each instance holds two pieces of data: the recipe’s name (String, line 13) and its calorie count per serving (Int, line 14). Together, the elements form the complete pool of recipes the app can draw from when filtering down to those that fall within the user’s chosen calorie range.
Question 7
Explain how use of the array manages complexity in this program. In your response, explain why the program could not be written — or how it would have to be written differently — if the array were not used.
SOLUTION
The
recipesarray manages complexity by storing all ten recipes in a single named collection rather than as ten separate sets of variables. Without it, each recipe would need its own variables (recipe1Name,recipe1Calories,recipe2Name, and so on) — twenty variables in total.The filtering logic depends on the array too. The
forloop on line 80 iterates overrecipesto test each calorie count against both bounds; without an array, this would have to be ten separateif-statements, one per recipe, each repeating the same comparison. TheListon line 156 also relies on iterating a collection — without it, ten rows would have to be written out by hand, and any layout change repeated ten times. The array makes the program shorter, easier to read, and easier to extend: adding an eleventh recipe means adding one entry to the array, not editing the filtering code and the view.
Question 8
Identify where a function is defined in the program. What is the function’s name? What is its return type, if any? What are the names of any parameter(s) and the data type of the parameter(s)?
SOLUTION
The function is defined on line 76. Its name is
includeRecipesInRangeFrom, and its return type is[Recipe]— an array ofRecipevalues.It defines three parameters:
recipesof type[Recipe],minCaloriesof typeDouble, andmaxCaloriesof typeDouble. None of the parameters uses a distinct external label, so the function is called asincludeRecipesInRangeFrom(recipes:minCalories:maxCalories:).
Question 9
Where is this function called (invoked, or used) within the program?
SOLUTION
The function is called on line 141, inside the body of
RecipeView, asviewModel.includeRecipesInRangeFrom(recipes: viewModel.recipes, minCalories: viewModel.minCalories, maxCalories: viewModel.maxCalories). The result is stored in the local constantmatchingRecipesand used to drive theListimmediately below. Because the call sits inside thebodyproperty, SwiftUI re-runs it any timeminCaloriesormaxCalorieschanges — so the function is effectively called once each time the user moves either slider.
Question 10
What is the purpose of the function, and how does it contribute to the overall functionality of the program?
SOLUTION
The
includeRecipesInRangeFromfunction takes the full pool of recipes and returns only those whose calorie count is at or above the user’s minimum and at or below the user’s maximum — that is, the recipes that fall inside the chosen calorie range.It connects user input to the displayed output. When the user moves either slider, the view re-evaluates the call on line 141, the function produces a new filtered array, and SwiftUI re-renders the
Listto match — either showing the matching recipes or, if the result is empty, theContentUnavailableViewon lines 149–153.
Question 11
Use point-form English to explain how the function uses sequence, selection, and iteration to accomplish its purpose. Your explanation should be detailed enough for someone else to reproduce the function. Please do not simply repeat back the lines of code that exist in the function.
SOLUTION
- (Sequence) The function receives three inputs: the pool of recipes to filter, the minimum calorie count the user will accept, and the maximum calorie count the user will accept.
- (Sequence) It creates an empty array that will hold the recipes that pass the filter.
- (Iteration) It loops over every recipe in the input pool, one at a time, in order.
- (Selection) On each pass, it checks two things at once: whether the current recipe’s calorie count is greater than or equal to the minimum, and whether the same count is less than or equal to the maximum (after converting the bounds from decimal slider values to whole numbers for the comparison).
- (Sequence) When both parts of the check pass, the recipe is appended to the result array; if either part fails, the recipe is skipped and the loop moves on.
- (Iteration continues) The loop continues until every recipe in the pool has been examined exactly once.
- (Sequence) Once the loop finishes, the function returns the result array — which now contains only the recipes whose calorie count sits inside the chosen range.
Question 12
Look at the provided screenshots. Now, describe a scenario where two separate calls to the function result in the outcomes shown in two of the screenshots. What would the arguments to the function have been in each case?
SOLUTION
Consider a user who first sets the sliders to a minimum of 200 calories and a maximum of 600 calories (screenshot 2), then drags both sliders to the same value of 300 calories (screenshot 3).
On the first call, the arguments are
recipes: viewModel.recipes(the full pool of ten recipes),minCalories: 200.0, andmaxCalories: 600.0.On the second call, the arguments are
recipes: viewModel.recipes(the same full pool),minCalories: 300.0, andmaxCalories: 300.0.
Question 13
Given the two situations you described in question 12, what conditions would be tested within the function? How do different arguments change what happens inside the function?
SOLUTION
Both calls test the same compound condition on line 81:
recipe.calories >= Int(minCalories) && recipe.calories <= Int(maxCalories). What changes between the two calls is the values ofminCaloriesandmaxCaloriesbeing compared against.On the first call,
minCaloriesis 200 andmaxCaloriesis 600. The condition istruefor six recipes — Margherita Pizza (570), Chicken Stir Fry (390), Grilled Salmon (350), Caesar Salad (280), Mushroom Risotto (430), and Avocado Toast (310) — which are appended to the result. The condition isfalsefor Greek Salad (180) and Vegetable Soup (120), which fall below the minimum, andfalsefor Beef Burger (650) and Spaghetti Carbonara (680), which exceed the maximum. This call is also a useful illustration of why both parts of the&&are needed: each bound rules out a different pair of recipes.On the second call,
minCaloriesis 300 andmaxCaloriesis 300. The compound condition is onlytruefor a recipe whose calorie count is exactly 300. No recipe in the pool has exactly 300 calories (Avocado Toast at 310 and Caesar Salad at 280 are the closest), so the condition isfalsefor every recipe and none is ever appended.
Question 14
Given the two situations you described in questions 12 and 13, what would the result of each situation be? In other words, what is returned from the function in each case?
SOLUTION
After the first call, the function returns an array of six
Recipevalues: “Margherita Pizza” (570 cal), “Chicken Stir Fry” (390 cal), “Grilled Salmon” (350 cal), “Caesar Salad” (280 cal), “Mushroom Risotto” (430 cal), and “Avocado Toast” (310 cal). SwiftUI uses this array to populate theList, producing the six rows shown in screenshot 2.After the second call, the function returns an empty
[Recipe]array. Theif matchingRecipes.isEmptycheck on line 147 is nowtrue, so SwiftUI displays theContentUnavailableViewon lines 149–153 instead of aList— producing the “No Recipes Found” screen shown in screenshot 3.
Version B – Pink
Question 1
Describe the overall purpose of the program.
SOLUTION
This program helps a hiker find trails that fit their current level of physical fitness. The user adjusts two sliders — one for the maximum trail length they are willing to walk, and one for the maximum elevation gain they are willing to climb — and the app displays a filtered list of trails whose length and elevation gain are both within those limits, so the user can choose a hike that matches their ability.
Question 2
Describe where input and output occur in the running of the program. Identify the specific line(s) of code responsible for each.
SOLUTION
Input occurs through two sliders. The maximum length slider on line 99 binds to
viewModel.maxLength, and the maximum elevation gain slider on line 112 binds toviewModel.maxElevationGain. Each time the user drags a slider, the bound property updates.Output occurs in several places. Lines 95 and 108 display the current slider values in the header. The
Liston line 138 outputs one row per matching trail, showing the trail’s name on line 140, its length on line 144, and its elevation gain on line 148. When no trails match, theContentUnavailableViewon lines 131–135 is shown instead.
Question 3
Identify where data is first stored in an array. Reference the specific line(s) of code that accomplish this.
SOLUTION
Data is first stored in an array on line 28, where the
trailsproperty is declared and immediately initialized. FiveTrailinstances are created inline, beginning on line 29 with the entry for “Dundas Peak Trail” and ending on line 53 with the closing of the last entry for “Georgian Bay Cliffs Trail”.
Question 4
What is the name of the chosen array?
SOLUTION
trails
Question 5
Describe where the chosen array is used in the program — for example, where it is iterated over, where individual elements are accessed, or where existing data in the array is used to produce new data or drive behaviour.
SOLUTION
The array is used in two main places. First, it is passed into
suitableTrails(from:maxLength:maxElevationGain:)on line 124, where the function iterates over it on line 62 and accesses each element’slengthandelevationGainproperties on line 63 to decide whether to include the trail in its returned result.Second, the filtered array returned by that call is stored in the local constant
matchingTrailson line 123 and then driven through theListon line 138, which iterates over it to produce one row per matching trail. Each row reads the element’snameon line 140,lengthon line 144, andelevationGainon line 148.
Question 6
What does the data stored in the array represent within the program? Describe the type of data stored and what role it plays.
SOLUTION
Each element is an instance of the
Trailstruct (lines 9–17), representing one hiking trail. Each instance holds three pieces of data: the trail’s name (String, line 13), its length in kilometres (Double, line 14), and its elevation gain in metres (Int, line 15). Together, the elements form the complete pool of trails the app can draw from when filtering down to those that match the user’s fitness limits.
Question 7
Explain how use of the array manages complexity in this program. In your response, explain why the program could not be written — or how it would have to be written differently — if the array were not used.
SOLUTION
The
trailsarray manages complexity by storing all five trails in a single named collection rather than as five separate sets of variables. Without it, each trail would need its own variables (trail1Name,trail1Length,trail1Elevation,trail2Name, and so on) — fifteen variables in total.The filtering logic depends on the array too. The
forloop on line 62 iterates overtrailsto test each trail against both limits; without an array, this would have to be five separateif-statements, one per trail, each repeating the same comparison. TheListon line 138 also relies on iterating a collection — without it, five rows would have to be written out by hand, and any layout change repeated five times. The array makes the program shorter, easier to read, and easier to extend: adding a sixth trail means adding one entry to the array, not editing the filtering code and the view.
Question 8
Identify where a function is defined in the program. What is the function’s name? What is its return type, if any? What are the names of any parameter(s) and the data type of the parameter(s)?
SOLUTION
The function is defined on line 58. Its name is
suitableTrails, and its return type is[Trail]— an array ofTrailvalues.It defines three parameters:
trailsof type[Trail],maxLengthof typeDouble, andmaxElevationGainof typeDouble. The first parameter uses the external labelfrom, so the function is called assuitableTrails(from:maxLength:maxElevationGain:).
Question 9
Where is this function called (invoked, or used) within the program?
SOLUTION
The function is called on line 123, inside the body of
TrailView, asviewModel.suitableTrails(from: viewModel.trails, maxLength: viewModel.maxLength, maxElevationGain: viewModel.maxElevationGain). The result is stored in the local constantmatchingTrailsand used to drive theListimmediately below. Because the call sits inside thebodyproperty, SwiftUI re-runs it any timemaxLengthormaxElevationGainchanges — so the function is effectively called once each time the user moves either slider.
Question 10
What is the purpose of the function, and how does it contribute to the overall functionality of the program?
SOLUTION
The
suitableTrailsfunction takes the full pool of trails and returns only those whose length is at or below the user’s maximum length and whose elevation gain is at or below the user’s maximum elevation gain.It connects user input to the displayed output. When the user moves either slider, the view re-evaluates the call on line 123, the function produces a new filtered array, and SwiftUI re-renders the
Listto match — either showing the matching trails or, if the result is empty, theContentUnavailableViewon lines 131–135.
Question 11
Use point-form English to explain how the function uses sequence, selection, and iteration to accomplish its purpose. Your explanation should be detailed enough for someone else to reproduce the function. Please do not simply repeat back the lines of code that exist in the function.
SOLUTION
- (Sequence) The function receives three inputs: the pool of trails to filter, the maximum length the user is willing to walk, and the maximum elevation gain the user is willing to climb.
- (Sequence) It creates an empty array that will hold the trails that pass the filter.
- (Iteration) It loops over every trail in the input pool, one at a time, in order.
- (Selection) On each pass, it checks two things at once: whether the current trail’s length is less than or equal to the maximum length, and whether the current trail’s elevation gain is less than or equal to the maximum elevation gain (after converting the maximum from a decimal value to a whole number for the comparison).
- (Sequence) When both parts of the check pass, the trail is appended to the result array; if either part fails, the trail is skipped and the loop moves on.
- (Iteration continues) The loop continues until every trail in the pool has been examined exactly once.
- (Sequence) Once the loop finishes, the function returns the result array — which now contains only the trails that fit both limits.
Question 12
Look at the provided screenshots. Now, describe a scenario where two separate calls to the function result in the outcomes shown in two of the screenshots. What would the arguments to the function have been in each case?
SOLUTION
Consider a hiker who first sets the sliders to a maximum length of 12.0 km and a maximum elevation gain of 625 m (screenshot 2), then drags both sliders down to a maximum length of 1.0 km and a maximum elevation gain of 50 m (screenshot 3).
On the first call, the arguments are
trails: viewModel.trails(the full pool of five trails),maxLength: 12.0, andmaxElevationGain: 625.0.On the second call, the arguments are
trails: viewModel.trails(the same full pool),maxLength: 1.0, andmaxElevationGain: 50.0.
Question 13
Given the two situations you described in question 12, what conditions would be tested within the function? How do different arguments change what happens inside the function?
SOLUTION
Both calls test the same compound condition on line 63:
trail.length <= maxLength && trail.elevationGain <= Int(maxElevationGain). What changes between the two calls is the values ofmaxLengthandmaxElevationGainbeing compared against.On the first call,
maxLengthis 12.0 andmaxElevationGainis 625. The condition istruefor three trails — Rattlesnake Point Loop (4.6 km, 175 m), Devil’s Glen Escarpment (11.8 km, 520 m), and Northumberland Forest Trail (8.2 km, 155 m) — which are appended to the result. The condition isfalsefor Dundas Peak Trail (its length 9.3 km is fine, but its 650 m elevation gain exceeds 625) andfalsefor Georgian Bay Cliffs Trail (both 22.1 km and 890 m exceed the limits). This call is also a useful illustration of why the two parts of the&&are both needed: Dundas Peak passes the length test but fails the elevation test, and is correctly excluded.On the second call,
maxLengthis 1.0 andmaxElevationGainis 50. Every trail in the pool has both a length above 1.0 km and an elevation gain above 50 m, so the compound condition isfalsefor every trail and none is ever appended.
Question 14
Given the two situations you described in questions 12 and 13, what would the result of each situation be? In other words, what is returned from the function in each case?
SOLUTION
After the first call, the function returns an array of three
Trailvalues: “Rattlesnake Point Loop” (4.6 km, 175 m gain), “Devil’s Glen Escarpment” (11.8 km, 520 m gain), and “Northumberland Forest Trail” (8.2 km, 155 m gain). SwiftUI uses this array to populate theList, producing the three rows shown in screenshot 2.After the second call, the function returns an empty
[Trail]array. Theif matchingTrails.isEmptycheck on line 129 is nowtrue, so SwiftUI displays theContentUnavailableViewon lines 131–135 instead of aList— producing the “No Trails Found” screen shown in screenshot 3.
Version C – Blue
Question 1
Describe the overall purpose of the program.
SOLUTION
This program helps students plan a study session. The user adjusts two sliders — one for the total session length, one for the number of breaks — and the app calculates the available study time (session length minus the time used by breaks). It then displays a filtered list of study tasks whose individual durations fit within that available time, so the user can choose tasks they can realistically complete in the time they have.
Question 2
Describe where input and output occur in the running of the program. Identify the specific line(s) of code responsible for each.
SOLUTION
Input occurs through two sliders. The session length slider on line 121 binds to
viewModel.sessionLength, and the number of breaks slider on line 134 binds toviewModel.numberOfBreaks. Each time the user drags a slider, the bound property updates.Output occurs in several places. Lines 117 and 130 display the current slider values in the header. Line 139 displays the calculated available study time. The
Liston line 166 outputs one row per fitting task, showing the task’s name on line 168 and its duration on line 171. When no tasks fit, theContentUnavailableViewon lines 159–163 is shown instead.
Question 3
Identify where data is first stored in an array. Reference the specific line(s) of code that accomplish this.
SOLUTION
Data is first stored in an array on line 29, where the
tasksproperty is declared and immediately initialized. TenStudyTaskinstances are created inline, beginning on line 30 with the entry for “Review class notes” and ending on line 69 with the closing of the last entry for “Memorise key definitions”.
Question 4
What is the name of the chosen array?
SOLUTION
tasks
Question 5
Describe where the chosen array is used in the program — for example, where it is iterated over, where individual elements are accessed, or where existing data in the array is used to produce new data or drive behaviour.
SOLUTION
The array is used in two main places. First, it is passed into
fittingTasks(from:sessionLength:numberOfBreaks:)on line 152, where the function iterates over it on line 83 and accesses each element’sdurationproperty on line 84 to decide whether to include the task in its returned result.Second, the filtered array returned by that call is stored in the local constant
fittingTaskson line 151 and then driven through theListon line 166, which iterates over it to produce one row per fitting task. Each row reads the element’snameon line 168 anddurationon line 171.
Question 6
What does the data stored in the array represent within the program? Describe the type of data stored and what role it plays.
SOLUTION
Each element is an instance of the
StudyTaskstruct (lines 9–16), representing one possible study activity. Each instance holds two pieces of data: the task’s name (String, line 13) and its duration in minutes (Int, line 14). Together, the elements form the complete pool of study tasks the app can draw from when filtering down to those that fit the user’s available time.
Question 7
Explain how use of the array manages complexity in this program. In your response, explain why the program could not be written — or how it would have to be written differently — if the array were not used.
SOLUTION
The
tasksarray manages complexity by storing all ten study activities in a single named collection rather than as ten separate sets of variables. Without it, each task would need its own variables (task1Name,task1Duration,task2Name,task2Duration, and so on) — twenty variables in total.The filtering logic depends on the array too. The
forloop on line 83 iterates overtasksto test each duration against the available time; without an array, this would have to be ten separateif-statements, one per task, each repeating the same comparison. TheListon line 166 also relies on iterating a collection — without it, ten rows would have to be written out by hand, and any layout change repeated ten times. The array makes the program shorter, easier to read, and easier to extend: adding an eleventh task means adding one entry to the array, not editing the filtering code and the view.
Question 8
Identify where a function is defined in the program. What is the function’s name? What is its return type, if any? What are the names of any parameter(s) and the data type of the parameter(s)?
SOLUTION
The function is defined on line 77. Its name is
fittingTasks, and its return type is[StudyTask]— an array ofStudyTaskvalues.It defines three parameters:
tasksof type[StudyTask],sessionLengthof typeDouble, andnumberOfBreaksof typeInt. The first parameter uses the external labelfrom, so the function is called asfittingTasks(from:sessionLength:numberOfBreaks:).
Question 9
Where is this function called (invoked, or used) within the program?
SOLUTION
The function is called on line 151, inside the body of
StudyView, asviewModel.fittingTasks(from: viewModel.tasks, sessionLength: viewModel.sessionLength, numberOfBreaks: Int(viewModel.numberOfBreaks)). The result is stored in the local constantfittingTasksand used to drive theListimmediately below. Because the call sits inside thebodyproperty, SwiftUI re-runs it any timesessionLengthornumberOfBreakschanges — so the function is effectively called once each time the user moves either slider.
Question 10
What is the purpose of the function, and how does it contribute to the overall functionality of the program?
SOLUTION
The
fittingTasksfunction takes the full pool of study tasks and returns only those whose duration is short enough to fit within the available study time (the session length minus the time used by breaks).It connects user input to the displayed output. When the user moves either slider, the view re-evaluates the call on line 151, the function produces a new filtered array, and SwiftUI re-renders the
Listto match — either showing the matching tasks or, if the result is empty, theContentUnavailableViewon lines 159–163.
Question 11
Use point-form English to explain how the function uses sequence, selection, and iteration to accomplish its purpose. Your explanation should be detailed enough for someone else to reproduce the function. Please do not simply repeat back the lines of code that exist in the function.
SOLUTION
- (Sequence) The function receives three inputs: the pool of tasks to filter, the session length in minutes, and the number of breaks the user has chosen.
- (Sequence) It calculates the available study time by multiplying the number of breaks by the fixed break duration (10 minutes), then subtracting that total from the session length. The result is stored in a local constant.
- (Sequence) It creates an empty array that will hold the tasks that pass the filter.
- (Iteration) It loops over every task in the input pool, one at a time, in order.
- (Selection) On each pass, it checks whether the current task’s duration is less than or equal to the available study time.
- (Sequence) When the check passes, the task is appended to the result array; when it fails, the task is skipped and the loop moves on.
- (Iteration continues) The loop continues until every task in the pool has been examined exactly once.
- (Sequence) Once the loop finishes, the function returns the result array — which now contains only the tasks short enough to fit.
Question 12
Look at the provided screenshots. Now, describe a scenario where two separate calls to the function result in the outcomes shown in two of the screenshots. What would the arguments to the function have been in each case?
SOLUTION
Consider a student who first sets the sliders to a 45-minute session with 3 breaks (screenshot 2), then drags the session-length slider down to 10 minutes with 1 break (screenshot 3).
On the first call, the arguments are
tasks: viewModel.tasks(the full pool of ten tasks),sessionLength: 45.0, andnumberOfBreaks: 3. The available study time works out to 45 − (3 × 10) = 15 minutes.On the second call, the arguments are
tasks: viewModel.tasks(the same full pool),sessionLength: 10.0, andnumberOfBreaks: 1. The available study time works out to 10 − (1 × 10) = 0 minutes.
Question 13
Given the two situations you described in question 12, what conditions would be tested within the function? How do different arguments change what happens inside the function?
SOLUTION
Both calls test the same condition on line 84:
task.duration <= availableTime. What changes between the two calls is the value ofavailableTime, which is computed from the arguments on line 79.On the first call,
availableTimeis 15. The condition istruefor the four tasks with durations of 10 or 15 minutes (“Review class notes”, “Flashcard practice”, “Watch a review video”, “Memorise key definitions”) andfalsefor the other six. Those four tasks are appended to the result.On the second call,
availableTimeis 0. The conditiontask.duration <= 0isfalsefor every task in the pool (the shortest task is 10 minutes), so no task is ever appended.
Question 14
Given the two situations you described in questions 12 and 13, what would the result of each situation be? In other words, what is returned from the function in each case?
SOLUTION
After the first call, the function returns an array of four
StudyTaskvalues: “Review class notes” (10 min), “Flashcard practice” (15 min), “Watch a review video” (15 min), and “Memorise key definitions” (10 min). SwiftUI uses this array to populate theList, producing the four rows shown in screenshot 2.After the second call, the function returns an empty
[StudyTask]array. Theif fittingTasks.isEmptycheck on line 157 is nowtrue, so SwiftUI displays theContentUnavailableViewon lines 159–163 instead of aList— producing the “No Tasks Fit” screen shown in screenshot 3.