“Every instance of a type has an implicit property called self, which is exactly equivalent to the instance itself. You use the self property to refer to the current instance within its own instance methods.”
Excerpt From: Apple Inc. “The Swift Programming Language (Swift 2).” iBooks.
The Swift Programming Languageにこのようにあるように、自分自身のインスタンスを表します。
通常はselfをいちいち書く必要はありません。書かなくてもSwiftコンパイラが自動的にselfが付いているものとして扱ってくれます。
“struct Point {
var x = 0.0, y = 0.0
func isToTheRightOfX(x: Double) -> Bool {
return self.x > x
}
}”
Excerpt From: Apple Inc. “The Swift Programming Language (Swift 2).” iBooks. https://itun.es/jp/jEUH0.l
上記のように、selfを省略すると引数のxとインスタンス変数のxと区別がつかない、などの場合はselfを付けて区別します。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/02/12 01:49