What does the underscore mean in this case?

后端 未结 1 806
故里飘歌
故里飘歌 2020-12-02 02:11

my code before the migation to Swift 2.0:

   override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
    if (segue.identifier == \"Rhym         


        
1条回答
  •  天命终不由人
    2020-12-02 02:45

    _ is a placeholder. It means that the values assigned to _ are ignored.

    Xcode's migration tool made this changes because it has detected that you didn't use source or myArray anywhere, thus replaced these variables by the placeholder.

    Now instead of being assigned to a variable, the returning result of segue.sourceViewController as! RhymeViewController and the returning result of [String]() are ignored.

    The returning result is ignored but the expression is still evaluated at runtime: if it has side effects, these effects will occur.

    So if you actually don't need these instructions you should get rid of them entirely.

    0 讨论(0)
提交回复
热议问题