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

回答編集履歴

3

修正

2016/12/27 13:40

投稿

_Kentarou
_Kentarou

スコア8490

answer CHANGED
@@ -1,4 +1,5 @@
1
1
  `Swift3`から戻り値を使うことが強要されるようになりました、使わないとワーニングが出ますので以下のように「アンダーバー」で受けてください。
2
+ 参考URL: [Defaulting non-Void functions so they warn on unused results](https://github.com/apple/swift-evolution/blob/master/proposals/0047-nonvoid-warn.md)
2
3
 
3
4
  ```swift
4
5
  _ = self.navigationController?.popToRootViewController(animated: true)

2

修正

2016/12/27 13:40

投稿

_Kentarou
_Kentarou

スコア8490

answer CHANGED
@@ -1,7 +1,7 @@
1
1
  `Swift3`から戻り値を使うことが強要されるようになりました、使わないとワーニングが出ますので以下のように「アンダーバー」で受けてください。
2
2
 
3
3
  ```swift
4
- _ = self.navigationController?.popViewController(animated: true)
4
+ _ = self.navigationController?.popToRootViewController(animated: true)
5
5
  ```
6
6
 
7
7
  `@discardableResult`を付けると戻り値を使わなくてもワーニングにならないようにできます。

1

修正

2016/12/27 13:31

投稿

_Kentarou
_Kentarou

スコア8490

answer CHANGED
@@ -2,4 +2,12 @@
2
2
 
3
3
  ```swift
4
4
  _ = self.navigationController?.popViewController(animated: true)
5
+ ```
6
+
7
+ `@discardableResult`を付けると戻り値を使わなくてもワーニングにならないようにできます。
8
+
9
+ ```swift
10
+ @discardableResult func doSomething() -> Bool {
11
+ return true
12
+ }
5
13
  ```