The
{ (game: Game) -> Bool in game.highestScore == highestScore && game.playedCount == playedCount }
closure is equivalent to:{ $0.highestScore == highestScore && $1.playedCount == playedCount }
{ $0.highestScore == highestScore && $0.playedCount == playedCount }
{ 0 -> 0.highestScore == highestScore && 0.playedCount == playedCount }
The
closure { return condition($0) }
is equivalent to:{ (number: Int) -> Bool in return condition(number) }
{ (number -> Bool) -> Int in condition <- (number) }
{ 0 -> condition(number) }
A function type specifies:
The parameter and return types for the function.
Only the parameter names required for the function.
The required function name and the return value without any details about the parameters.
Which of the following lines declare a variable with a function type:
var condition: { 0 -> Int -> Bool }
var condition: Int $0 returns Bool
var condition: (Int -> Bool)
After...
Argentina
Australia
Austria
Belgium
Brazil
Bulgaria
Canada
Chile
Colombia
Cyprus
Czechia
Denmark
Ecuador
Egypt
Estonia
Finland
France
Germany
Great Britain
Greece
Hungary
India
Indonesia
Ireland
Italy
Japan
Latvia
Lithuania
Luxembourg
Malaysia
Malta
Mexico
Netherlands
New Zealand
Norway
Philippines
Poland
Portugal
Romania
Russia
Singapore
Slovakia
Slovenia
South Africa
South Korea
Spain
Sweden
Switzerland
Taiwan
Thailand
Turkey
Ukraine
United States