@@ -1229,7 +1229,7 @@ after the name of the type that the optional contains ---
12291229for example, the type of an optional ` Int ` is ` Int? ` .
12301230An optional ` Int ` always contains
12311231either some ` Int ` value or no value at all.
1232- It can't contain anything else, like a ` Bool ` value or a ` String ` value.
1232+ It can't contain anything else, like a ` Bool ` or ` String ` value.
12331233
12341234### nil
12351235
@@ -1256,7 +1256,7 @@ serverResponseCode = nil
12561256-->
12571257
12581258If you define an optional variable without providing a default value,
1259- the variable is automatically set to ` nil ` for you :
1259+ the variable is automatically set to ` nil ` :
12601260
12611261``` swift
12621262var surveyAnswer: String ?
@@ -1277,7 +1277,7 @@ by comparing the optional against `nil`.
12771277You perform this comparison with the “equal to” operator (` == ` )
12781278or the “not equal to” operator (` != ` ).
12791279
1280- If an optional has a value, it's considered to be “not equal to” ` nil ` :
1280+ If an optional has a value, it's considered as “not equal to” ` nil ` :
12811281
12821282``` swift
12831283let possibleNumber = " 123"
@@ -1304,14 +1304,14 @@ You can't use `nil` with non-optional constants or variables.
13041304If a constant or variable in your code needs to work with
13051305the absence of a value under certain conditions,
13061306declare it as an optional value of the appropriate type.
1307- A constant or variable that's declared as a non-optional value,
1307+ A constant or variable that's declared as a non-optional value
13081308is guaranteed to never contain a ` nil ` value.
13091309If you try to assign ` nil ` to a non-optional value,
13101310you'll get a compile-time error.
13111311
13121312This separation of optional and non-optional values
13131313lets you explicitly mark what information can be missing,
1314- and makes it easier to write correct code that handle missing values.
1314+ and makes it easier to write code that handle missing values.
13151315You can't accidentally treat an optional as if it were non-optional
13161316because this mistake produces an error at compile time.
13171317After you unwrap the value,
@@ -1322,7 +1322,7 @@ in different parts of your code.
13221322When you access an optional value,
13231323your code always handles both the ` nil ` and non-` nil ` case.
13241324There are several things you can do when a value is missing,
1325- which are described in more detail in the following sections:
1325+ as described in the following sections:
13261326
13271327- Skip the code that operates on the value when it's ` nil ` .
13281328
@@ -1392,9 +1392,9 @@ set a new constant called `actualNumber` to the value contained in the optional.
13921392If the conversion is successful,
13931393the ` actualNumber ` constant becomes available for use within
13941394the first branch of the ` if ` statement.
1395- It has already been initialized with the value contained * within* the optional,
1395+ It has already been initialized with the value contained within the optional,
13961396and has the corresponding non-optional type.
1397- In this case, the type of ` possibleNumber ` is ` Int? `
1397+ In this case, the type of ` possibleNumber ` is ` Int? ` ,
13981398so the type of ` actualNumber ` is ` Int ` .
13991399
14001400If you don't need to refer to the original, optional constant or variable
@@ -1431,8 +1431,8 @@ If `myNumber` has a value,
14311431the value of a new constant named ` myNumber ` is set to that value.
14321432Inside the body of the ` if ` statement,
14331433writing ` myNumber ` refers to that new non-optional constant.
1434- Before the beginning of the ` if ` statement and after its end,
1435- writing ` myNumber ` refers to the original optional integer constant.
1434+ Writing ` myNumber ` before or after the ` if ` statement
1435+ refers to the original optional integer constant.
14361436
14371437Because this kind of code is so common,
14381438you can use a shorter spelling to unwrap an optional value:
@@ -1532,9 +1532,9 @@ as described in <doc:ControlFlow#Early-Exit>.
15321532
15331533Another way to handle a missing value is to supply
15341534a default value using the nil-coalescing operator (` ?? ` ).
1535- If the optional on the left side of the ` ?? ` isn't ` nil ` ,
1535+ If the optional on the left of the ` ?? ` isn't ` nil ` ,
15361536that value is unwrapped and used.
1537- Otherwise, the value on the right side of ` ?? ` is used.
1537+ Otherwise, the value on the right of ` ?? ` is used.
15381538For example,
15391539the code below greets someone by name if one is specified,
15401540and uses a generic greeting when the name is ` nil ` .
@@ -1591,11 +1591,11 @@ Both versions of the code above depend on `convertedNumber`
15911591always containing a value.
15921592Writing that requirement as part of the code,
15931593using either of the approaches above,
1594- lets your code check that the requirement is true at run time .
1594+ lets your code check that the requirement is true at runtime .
15951595
15961596For more information about enforcing data requirements
15971597and checking assumptions at runtime,
1598- see < doc:TheBasics#Assertions-and-Preconditions > below .
1598+ see < doc:TheBasics#Assertions-and-Preconditions > .
15991599
16001600### Implicitly Unwrapped Optionals
16011601
@@ -1897,11 +1897,11 @@ for recoverable or expected errors.
18971897Because a failed assertion or precondition
18981898indicates an invalid program state,
18991899there's no way to catch a failed assertion.
1900- Trying to recover from an invalid state isn't possible ---
1901- because the assertion failed,
1902- you know that at least one piece of the program's data is invalid,
1900+ Recovering from an invalid state is impossible.
1901+ When an assertion fails,
1902+ at least one piece of the program's data is invalid ---
19031903but you don't know why it's invalid
1904- or what additional state is also invalid.
1904+ or whether an additional state is also invalid.
19051905
19061906Using assertions and preconditions
19071907isn't a substitute for designing your code in such a way
0 commit comments