樓下xcode8更新的 方法這樣寫 PlaygroundPage.current.liveView= showView
2016-10-25
在xcode8中需要 import PlaygroundSupport 而不是XCPlayground,在需要的地方使用PlaygroundPage.current.livePage = showView
2016-10-24
//返回函數(shù)類型 函數(shù)嵌套
func tw1(w:Int) -> Int{
return 1*w;
}
func tw3(w:Int) -> Int{
return 3*w;
}
func fp(p:Int,w:Int) -> Int {
//返回類型是函數(shù)
func cw(w:Int) -> ((Int) -> Int){
return w <= 10 ? tw1:tw3;
}
let m = cw(w:w);
return m(w) + p*w;
}
func tw1(w:Int) -> Int{
return 1*w;
}
func tw3(w:Int) -> Int{
return 3*w;
}
func fp(p:Int,w:Int) -> Int {
//返回類型是函數(shù)
func cw(w:Int) -> ((Int) -> Int){
return w <= 10 ? tw1:tw3;
}
let m = cw(w:w);
return m(w) + p*w;
}
2016-10-16
目前xcode8.0下支持的寫法應(yīng)為var allzeros=[Int](repeating:0,count:5)
2016-10-15
swift3.0 func swapTwoInts1(a:inout Int , _ b:inout Int)
2016-10-14
swift3.0中inout關(guān)鍵字放在了參數(shù)的后面
2016-10-09
最新回答 / Code_淺藍(lán)
func sayHello(to name:String = "Playground", withGreetingWord greadting:String = "Hello", punctuation:String = "!") -> String {? ? return "\(greadting),\(name)\(punctuation)"}sayHello()sayHello(to: "OC", withGreetingWord: "Bye", punctuation: "!!!")XCOD...
sayHelloTo(name: "Playground", greeting: "Welcome")