Warning の文を見出しとしてまとめます。
Curried function declaration syntax will be removed in a future version of Swift; use a single parameter list
Swift 3.0 でカリー化関数の構文が廃止が決定していますので、今から書き換えておこうね と Xcode が教えてくれます。
カリー化関数ってなんですか…?初めて聞きました…。
func curried(x: Int)(y: String) -> Float {
return Float(x) + Float(y)!
}
func curried(x: Int, y: String) -> Float {
return Float(x) + Float(y)!
}
func curried(x: Int) -> (String) -> Float {
return {(y: String) -> Float in
return Float(x) + Float(y)!
}
}
SE-0002: Removing currying func declaration syntax
'var' parameters are deprecated and will be removed in Swift 3
Swift 3.0 で関数の引数に var が使えなくなることが決定していますので、今から書き換えておこうね と Xcode が教えてくれます。
func foo(var i: Int) {
i += 1
}
func foo( i: Int) {
i += 1
}
Xcode の自動修正だと、結局はエラーになっちゃうんですよね…。
func foo(inout i: Int) {
i += 1
}
var x = 1
print(foo(&x))
この print
の結果は 2
です。
SE-0003: Removing var from Function Parameters
'++' is deprecated: it will be removed in Swift 3
Swift 3.0 で++
演算子の廃止が決定していますので、今から書き換えておこうね と Xcode が教えてくれます。
var x = 1
let a = ++x
let b = x++
var x = 1
let a = x += 1
let b = x += 1
いや、for
文とかで使うときはこの修正でいいんですけどね…。
var x = 1
x += 1
let a = x
let b = x
x += 1
successor メソッドを使ってもいいですね。
SE-0004: Remove the ++ and -- operators
'--' is deprecated: it will be removed in Swift 3
Swift 3.0 で--
演算子の廃止が決定していますので、今から書き換えておこうね と Xcode が教えてくれます。
var x = 1
let a = --x
let b = x--
var x = 1
let a = x -= 1
let b = x -= 1
var x = 1
x -= 1
let a = x
let b = x
x -= 1
SE-0004: Remove the ++ and -- operators
C-style for statement is deprecated and will be removed in a future version of Swift
これは結構有名かと思われますが、Swift 3.0 で C言語のようなfor
文が廃止されます。
for var i = 0; i <= 5; i += 1 {
print(i)
}
この書き方だと Xcode は自動修正してくれません。
for i in 0 ..< 5 {
print(i)
}
for/in
ループを使うようにすると解消できます。
SE-0007: Remove C-style for-loops with conditions and incrementers
とりあえず、急ぎで書いたので…
気が向いたら追記します…。