回答編集履歴
1
ref
test
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
`as!`でダウンキャストしているので、キャスト出来ないときに落ちます。
|
2
2
|
|
3
|
-
`as?`でダウンキャストし、Optional Binding(if let)でアンラップします。
|
3
|
+
`as?`でダウンキャストし、Optional Binding(`if let`)でアンラップします。
|
4
4
|
|
5
5
|
|
6
6
|
|
@@ -19,3 +19,11 @@
|
|
19
19
|
}
|
20
20
|
|
21
21
|
```
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
ref.
|
26
|
+
|
27
|
+
[Downcasting](https://docs.swift.org/swift-book/LanguageGuide/TypeCasting.html#ID341)
|
28
|
+
|
29
|
+
[Optional Binding](https://docs.swift.org/swift-book/LanguageGuide/TheBasics.html#ID333)
|