5
我的代碼:下劃線在這種情況下意味着什麼?在migation斯威夫特2.0之前
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
if (segue.identifier == "RhymeFavoriten") {
// pass data to next view
let dest = segue.destinationViewController as! FavoritenViewController
let source = segue.sourceViewController as! RhymeViewController // !!!!!!
dest.favoritenType = 1
dest.delegate = self
}
}
遷移告訴我將其更改爲
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
if (segue.identifier == "RhymeFavoriten") {
// pass data to next view
let dest = segue.destinationViewController as! FavoritenViewController
_ = segue.sourceViewController as! RhymeViewController // !!!!!!!!!!
dest.favoritenType = 1
dest.delegate = self
}
或
func textSelected(selectedText:String, selectedType:Int) {
var fullTextArr = text.componentsSeparatedByString("\n")
var myArray = [String]() // !!!!!!
到
func textSelected(selectedText:String, selectedType:Int) {
var fullTextArr = text.componentsSeparatedByString("\n")
_ = [String]() // !!!!!!!!!
我無法看到,什麼是_ =代表:-(
它們被忽略還是隻是一個編譯器優化,因爲沒有必要存儲一個引用到一個未使用的變量? – jarryd
它們被計算(評估),但返回的結果(如果有的話)沒有在內存中分配,它是無效的。 – Moritz
在編譯時而不是運行時評估 – jarryd