99热99这里只有精品6国产,亚洲中文字幕在线天天更新,在线观看亚洲精品国产福利片 ,久久久久综合网

歡迎加入QQ討論群258996829
Daniel 頭像
蘋果1袋
1
Daniel

蘋果Mac Pro垃圾桶 最低配的ME253CH

發(fā)布時(shí)間:2017-03-23 13:20  回復(fù):61  查看:31339   最后回復(fù):2017-05-31 21:13  
Swift 頭像
蘋果5袋
5
Swift   2017-03-29 18:53
@Daniel
I have difficulty to open the site that you said.
是的,需要用VPN才行。
Daniel 頭像
蘋果1袋
1
Daniel   2017-04-01 01:25
@Swift
@Daniel
I have difficulty to open the site that you said.
是的,需要用VPN才行。

What is VPN?

Your quoted site https://swift.sandbox.bluemix.net/#/repl will work on the following browers:

360極速瀏覽器, 2144瀏覽器, Google Chrome瀏覽器, 搜狗高速瀏覽器 及 UC瀏覽器.

Thank you very much.

Swift 頭像
蘋果5袋
5
Swift   2017-04-01 11:36

@Daniel 你能訪問就好。這里說的VPN指網(wǎng)絡(luò)代理,幫你訪問一些比較慢或無法訪問的網(wǎng)站。

Daniel 頭像
蘋果1袋
1
Daniel   2017-04-02 23:29

Since you have learned Swift (編程語言) more than a couple of years already, what suggestions and guidance will you give me for learning the language?

My first and current reading is [The Swift Programming Language (Swift 3.1)] with the help of the IBM Swift Sandbox interpreter. What else will you suggest?

Swift 頭像
蘋果5袋
5
Swift   2017-04-04 17:16
我2014年開始接觸Swift,那時(shí)也只是學(xué)了點(diǎn)基礎(chǔ)語法,沒有學(xué)習(xí)iOS的開發(fā),而且現(xiàn)在語法有變動(dòng),還得重新學(xué)習(xí)。所以我跟你一樣是個(gè)新手,所以目前給不了你什么建議。
后續(xù)網(wǎng)站會(huì)更新一些視頻教程,希望能夠?qū)δ阌杏谩?
Daniel 頭像
蘋果1袋
1
Daniel   2017-04-05 22:51
@Swift
我2014年開始接觸Swift,那時(shí)也只是學(xué)了點(diǎn)基礎(chǔ)語法,沒有學(xué)習(xí)iOS的開發(fā),而且現(xiàn)在語法有變動(dòng),還得重新學(xué)習(xí)。所以我跟你一樣是個(gè)新手,所以目前給不了你什么建議。
后續(xù)網(wǎng)站會(huì)更新一些視頻教程,希望能夠?qū)δ阌杏谩?

I tried the sample code in [Subscript Options] of [The Swift Programming Language (Swift 3.1)], I had compilation errors.

Can you help debugging ?

Swift 頭像
蘋果5袋
5
Swift   2017-04-05 23:23
@Daniel 把代碼發(fā)出來看看(通過點(diǎn)擊紅色的Swift圖標(biāo)插入程序代碼),我試一下看會(huì)不會(huì)出錯(cuò)。
Daniel 頭像
蘋果1袋
1
Daniel   2017-04-06 05:35
struct Matrix {
    let rows: Int, columns: Int
    var grid: [Double]
    init(rows: Int, columns: Int) {
        self.rows = rows
        self.columns = columns
        grid = Array(repeating: 0.0, count: rows * columns)
    }
    func indexIsValid(row: Int, column: Int) -> Bool {
        return row >= 0 && row < rows && column >= 0 && column < columns
    }
    subscript(row: Int, column: Int) -> Double {
        get {
            assert(indexIsValid(row: row, column: column), "Index out of range")
            return grid[(row * columns) + column]
        }
        set {
            assert(indexIsValid(row: row, column: column), "Index out of range")
            grid[(row * columns) + column] = newValue
        }
    }
}
var matrix = Matrix(rows: 2, columns: 2)
matrix[0, 1] = 1.5
matrix[1, 0] = 3.2
func indexIsValidForRow(row: Int, column: Int) -> Bool {
    return row >= 0 && row < rows && column >= 0 && column < columns
}
let someValue = matrix[2, 2]
// this triggers an assert, because [2, 2] is outside of the matrix bounds
Swift 頭像
蘋果5袋
5
Swift   2017-04-08 13:10

@Daniel 之前用Xcode7.1編譯出錯(cuò),今天裝了個(gè)Xcode8.3,indexIsValidForRow函數(shù)放到Matrix結(jié)構(gòu)體中就可以了。修改的代碼如下:

struct Matrix {
    let rows: Int, columns: Int
    var grid: [Double]
    init(rows: Int, columns: Int) {
        self.rows = rows
        self.columns = columns
        grid = Array(repeating: 0.0, count: rows * columns)
    }
    func indexIsValid(row: Int, column: Int) -> Bool {
        return row >= 0 && row < rows && column >= 0 && column < columns
    }
    subscript(row: Int, column: Int) -> Double {
        get {
            assert(indexIsValid(row: row, column: column), "Index out of range")
            return grid[(row * columns) + column]
        }
        set {
            assert(indexIsValid(row: row, column: column), "Index out of range")
            grid[(row * columns) + column] = newValue
        }
    }
    
    func indexIsValidForRow(row: Int, column: Int) -> Bool {
        return row >= 0 && row < rows && column >= 0 && column < columns
    }
}
var matrix = Matrix(rows: 2, columns: 2)
matrix[0, 1] = 1.5
matrix[1, 0] = 3.2

let someValue = matrix[1, 1]
// let someValue = matrix[2, 2]
// this triggers an assert, because [2, 2] is outside of the matrix bounds


Daniel 頭像
蘋果1袋
1
Daniel   2017-04-09 18:25

You are great!

Recently I bought 3 electronic books, but I will wait to read them until I purchase a new Mac Pro next year when it is available.蘋果Mac&nbsp;Pro垃圾桶&nbsp;最低配的ME253CH蘋果Mac&nbsp;Pro垃圾桶&nbsp;最低配的ME253CH蘋果Mac&nbsp;Pro垃圾桶&nbsp;最低配的ME253CH

Swift 頭像
蘋果5袋
5
Swift   2017-04-11 20:13

你這還要等很久啊,明年就得學(xué)Swift4了。

Daniel 頭像
蘋果1袋
1
Daniel   2017-04-12 08:16
I have no need to rush. I don't want to buy a current Mac Pro which will not be manufactured soon because a future Mac Pro is completely different from a current one. It is difficult to get the current model repaired in the future due to the eventual lack of its spare parts.
Also I need to spend about RMB50,000 to fix my teeth this year.

dkychang@qq.com

Swift 頭像
蘋果5袋
5
Swift   2017-04-12 22:10
是的,不急的話可以等下,就像iPhone8一樣,值得期待。
Daniel 頭像
蘋果1袋
1
Daniel   2017-04-24 10:17
Functions are a first-class type. This means that a function can return another function as its value: 
func makeIncrementer() -> ((Int) -> Int) {
    func addOne(number: Int) -> Int {
        return 1 + number
    }
    return addOne
}
var increment = makeIncrementer()
print(increment(7))
Swift is not easy, I don't understand the above code. Do you?

					
Swift 頭像
蘋果5袋
5
Swift   2017-04-24 13:16
//返回addOne這個(gè)函數(shù)
func makeIncrementer() -> ((Int) -> Int) {
    func addOne(number: Int) -> Int {
        return 1 + number
    }
    return addOne
}

//increment存放makeIncrementer()返回的函數(shù),即increment就是addOne()
var increment = makeIncrementer()

//實(shí)際就是調(diào)用了addOne(),輸出結(jié)果為8
print(increment(7))
Daniel 頭像
蘋果1袋
1
Daniel   2017-04-24 20:12

I still don't understand. 

Why increment can take an argument? 

makeIncrementer () takes NO argument.

Swift 頭像
蘋果5袋
5
Swift   2017-04-24 22:02

因?yàn)閕ncrement是addOne,addOne是帶參數(shù)的;makeIncrementer()定義時(shí)就時(shí)沒有參數(shù)。

你不要把increment當(dāng)成makeIncrementer(),increment只是makeIncrementer()返回的一個(gè)函數(shù)。在Java中可以理解為increment是makeIncrementer()返回的一個(gè)對(duì)象,區(qū)別就是在于在Java中函數(shù)不是class,而Swift中函數(shù)也算是class,所以在Swift中可以把一個(gè)函數(shù)作為返回值,也可以作為參數(shù)。

Daniel 頭像
蘋果1袋
1
Daniel   2017-04-28 08:55

func anyCommonElements<T: Sequence, U: Sequence>(_ lhs: T, _ rhs: U) -> Bool
    where T.Iterator.Element: Equatable, T.Iterator.Element == U.Iterator.Element {
        for lhsItem in lhs {
            for rhsItem in rhs {
                if lhsItem == rhsItem {
                    return true
                }
            }
        }
        return false
}
anyCommonElements([1, 2, 3], [3])
Another piece of code that I don't understand, maybe you can explain?


Swift 頭像
蘋果5袋
5
Swift   2017-04-29 17:47
//這個(gè)函數(shù)是用于判斷兩個(gè)數(shù)組中是否有相同元素
//<T: Sequence, U: Sequence> 這里用了泛型,指定了參數(shù)T和U的類型必須實(shí)現(xiàn)Sequence協(xié)議,即參數(shù)必須是數(shù)組或集合等可遍歷的
func anyCommonElements<T: Sequence, U: Sequence>(_ lhs: T, _ rhs: U) -> Bool
    //where子句是對(duì)泛型對(duì)參數(shù)T和U做了約束,調(diào)用函數(shù)時(shí)傳遞的參數(shù)達(dá)到以下2個(gè)條件才行
    //T.Iterator.Element: Equatable 參數(shù)T必須實(shí)現(xiàn)Equatable協(xié)議,實(shí)現(xiàn)Equatable協(xié)議的類型才可以使用 == 和 != 進(jìn)行比較
    //T.Iterator.Element == U.Iterator.Element 這句要求T和U的類型必須是相同的,例:要么都是字符,要么都是數(shù)字。
    where T.Iterator.Element: Equatable, T.Iterator.Element == U.Iterator.Element {
        
        //這里就是循環(huán)對(duì)比內(nèi)容了,一旦發(fā)現(xiàn)有相同的元素則返回true
        for lhsItem in lhs {
            for rhsItem in rhs {
                if lhsItem == rhsItem {
                    return true
                }
            }
        }
        return false
}

//這里結(jié)果是true,因?yàn)閮蓚€(gè)數(shù)組中都有3
anyCommonElements([1, 2, 3], [3, 4])


//上面調(diào)用時(shí)參數(shù)時(shí)用的數(shù)字,下面例子使用的字符,其它實(shí)現(xiàn)Equatable協(xié)議的類型也可以使用。
//這里結(jié)果是false
anyCommonElements(["1", "2"], ["3", "7"])

//總結(jié):泛型可以使同一個(gè)函數(shù),支持多種類型,而不需要為不同類型分別寫一個(gè)函數(shù)。

關(guān)于泛型可以參考:泛型 - Swift 3.0 教程

Daniel 頭像
蘋果1袋
1
Daniel   2017-04-30 06:38

I know the results of the examples because I tried the IBM compiler. But the terms (Sequence, Iterator and Equatable) have never been explained in the document [The Swift Programming Language (Swift 3.1)]?

Have you read other documents?

您還未登錄,請(qǐng)先登錄

熱門帖子

最新帖子

?