From 9320cc1e8dec53f6b3e9b0cf745a92f2793e389a Mon Sep 17 00:00:00 2001 From: Jasdev Singh Date: Mon, 20 Jan 2020 12:16:30 -0500 Subject: [PATCH] =?UTF-8?q?Update=20Episode=206=E2=80=99s=20Exercises=20pa?= =?UTF-8?q?ge=20to=20match=20transcript.=20(#31)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Contents.swift | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/0006-functional-setters/Functional Setters.playground/Pages/02-Exercises.xcplaygroundpage/Contents.swift b/0006-functional-setters/Functional Setters.playground/Pages/02-Exercises.xcplaygroundpage/Contents.swift index 08022755..aa766d39 100644 --- a/0006-functional-setters/Functional Setters.playground/Pages/02-Exercises.xcplaygroundpage/Contents.swift +++ b/0006-functional-setters/Functional Setters.playground/Pages/02-Exercises.xcplaygroundpage/Contents.swift @@ -5,32 +5,42 @@ */ // TODO /*: - 2. Take the following `User` struct and write a setter for its `name` property. Add another property, and add a setter for it. What are some potential issues with building these setters? - */ + 2. Take a `struct`, _e.g._: + +``` struct User { let name: String } +``` + + Write a setter for its property. Take (or add) another property, and add a setter for it. What are some potential issues with building these setters? + */ // TODO /*: - 3. Add a `location` property to `User`, which holds a `Location`, defined below. Write a setter for `userLocationName`. Now write setters for `userLocation` and `locationName`. How do these setters compose? - */ + 3. Take a `struct` with a nested `struct`, _e.g._: + +``` struct Location { let name: String } -// TODO -/*: - 4. Do `first` and `second` work with tuples of three or more values? Can we write `first`, `second`, `third`, and `nth` for tuples of _n_ values? + +struct User { + let location: Location +} +``` + + Write a setter for `userLocationName`. Now write setters for `userLocation` and `locationName`. How do these setters compose? */ // TODO /*: - 5. Write a setter for a dictionary that traverses into a key to set a value. + 4. Do `first` and `second` work with tuples of three or more values? Can we write `first`, `second`,`third`, and `nth` for tuples of _n_ values? */ // TODO /*: - 6. Write a setter for a dictionary that traverses into a key to set a value if and only if that value already exists. + 5. Write a setter for a dictionary that traverses into a key to set a value. */ // TODO /*: - 7. What is the difference between a function of the form `((A) -> B) -> (C) -> (D)` and one of the form `(A) -> (B) -> (C) -> D`? + 6. What is the difference between a function of the form `((A) -> B) -> (C) -> (D)` and one of the form `(A) -> (B) -> (C) -> D`? */ // TODO