Suggested changes

This commit is contained in:
Clayton Walker 2015-10-08 23:27:19 -04:00
parent ad16a31c07
commit b4860de42f

View File

@ -58,8 +58,8 @@ let piText = "Pi = \(π), Pi 2 = \(π * 2)" // String interpolation
print("Build value: \(buildValue)") // Build value: 7 print("Build value: \(buildValue)") // Build value: 7
/* /*
Optionals are a Swift language feature that either contains a value, Optionals are a Swift language feature that either contains a value,
or contains nil (no value) to indicate that a value is missing. or contains nil (no value) to indicate that a value is missing.
A question mark (?) after the type marks the value as optional. A question mark (?) after the type marks the value as optional.
Because Swift requires every property to have a value, even nil must be Because Swift requires every property to have a value, even nil must be
@ -82,9 +82,9 @@ if someOptionalString != nil {
someOptionalString = nil someOptionalString = nil
/* /*
To get the underlying type from an optional, you unwrap it using the Trying to use ! to access a non-existent optional value triggers a runtime
force unwrap operator (!). Only use the unwrap operator if you're sure error. Always make sure that an optional contains a non-nil value before
the underlying value isn't nil. using ! to force-unwrap its value.
*/ */
// implicitly unwrapped optional // implicitly unwrapped optional