Test your knowledge

  1. The { (game: Game) -> Bool in game.highestScore == highestScore && game.playedCount == playedCount } closure is equivalent to:
    1. { $0.highestScore == highestScore && $1.playedCount == playedCount }.
    2. { $0.highestScore == highestScore && $0.playedCount == playedCount }.
    3. { 0 -> 0.highestScore == highestScore && 0.playedCount == playedCount }.

  2. The closure { return condition($0) } is equivalent to:
    1. { (number: Int) -> Bool in return condition(number) }.
    2. { (number -> Bool) -> Int in condition <- (number) }.
    3. { 0 -> condition(number) }.

  3. A function type specifies:
    1. The parameter and return types for the function.
    2. Only the parameter names required for the function.
    3. The required function name and the return value without any details about the parameters.

  4. Which of the following lines declare a variable with a function type, considering that the syntax must be compatible with Swift 3?
    1. var condition: { 0 -> Int -> Bool }.
    2. var condition: Int $0 returns Bool.
    3. var condition: ((Int) -> Bool).

  5. After we assign a tuple to a variable with the line, var tuple: (key: String, value: String) = ("Name", "Garfield"), which of the following lines accesses the first string element in the tuple, that is, the value named key?
    1. tuple.$0.
    2. tuple.1.
    3. tuple.0.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.35.54