If we take parts of this code one by one:
let wordFreqs = [("k", 5), ("a", 7), ("b", 3)]
You start with an array of tuples .
In the Swift documentation:
A tuple type is a comma-separated list of types enclosed in parentheses.
and
Tuples group multiple values into one composite value. The values in the tuple can be of any type.
In this case, tuples are "pairs" of two values, one of the String type and one of the Int type.
let res = wordFreqs.filter(
{
(e) -> Bool in
. , e (, , ) Bool. "filter" true , false .
if e.1 > 3 {
return true
} else {
return false
}
e.1 1.
, 1 () 3, true ( ); , false (, , ).
[("k", 5), ("a", 7)]
}).map { $0.0 }
map : ($ 0) 0. , ["k", "a"]
print(res)
.
(, , ..) .
, , [1, 2, 3].filter({ }).map({ }).reduce({ })