map(_:)
let ranks = cards.map{ $0.Rank }
which is syntactic sugar for:
let ranks = cards.map({ (card: Card) -> Rank in
return card.rank
})
The applied syntactic sugar includes:
Trailing closure syntax
let ranks = cards.map { (card: Card) -> Rank in
return card.rank
}
Argument type inference
let ranks = cards.map { card -> Rank in
return card.rank
}
Return type inference
let ranks = cards.map { card in
return card.rank
}
Implicit return value
let ranks = cards.map { card in
card.rank
}
Anonymous closure arguments
let ranks = cards.map { $0.rank }
Check out the language guide section on closures (the Swift name for what C# calls lambdas) for more information,