teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

ref

2018/07/09 05:42

投稿

fuzzball
fuzzball

スコア16733

answer CHANGED
@@ -1,5 +1,5 @@
1
1
  `as!`でダウンキャストしているので、キャスト出来ないときに落ちます。
2
- `as?`でダウンキャストし、Optional Binding(if let)でアンラップします。
2
+ `as?`でダウンキャストし、Optional Binding(`if let`)でアンラップします。
3
3
 
4
4
 
5
5
  ```swift
@@ -8,4 +8,8 @@
8
8
  } else {
9
9
  print("is not CAShapeLayer")
10
10
  }
11
- ```
11
+ ```
12
+
13
+ ref.
14
+ [Downcasting](https://docs.swift.org/swift-book/LanguageGuide/TypeCasting.html#ID341)
15
+ [Optional Binding](https://docs.swift.org/swift-book/LanguageGuide/TheBasics.html#ID333)