Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c5f5332

Browse files
done with optionals and optional chaining
1 parent 4c702c7 commit c5f5332

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

‎Optionals/Optionals.playground/Contents.swift

100755100644
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,10 @@ if let intValue = zee {
112112

113113
var imageView = UIImageView()
114114

115+
115116
imageView.image = UIImage(named:"puppy_in_box")
117+
118+
116119
if let image = imageView.image {
117120
let size = image.size
118121
} else {
@@ -122,6 +125,9 @@ imageView.image
122125

123126
//: ### Optional Chaining
124127
// Example 1
128+
129+
// https://stackoverflow.com/questions/25828301/how-is-swift-if-let-evaluated
130+
125131
var anotherImageView = UIImageView()
126132
anotherImageView.image = UIImage(named:"puppy_in_box")
127133

@@ -159,6 +165,13 @@ class BetterViewController: UIViewController {
159165
var myButton: UIButton!
160166
}
161167

168+
//: ### DownCasting
169+
class Beverage {
170+
var category: String
171+
172+
173+
174+
}
162175
//: ### Optionals can be passed as parameters to functions
163176

164177
// Example: Picking up groceries in an optional car

‎Optionals/Optionals.playground/contents.xcplayground

100755100644
File mode changed.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /