mardi 3 juin 2014

Why does filters in Swift iterate the collection twice?


Vote count:

1




The following code in Swift's playground or Console App:



let letters = ["A", "B", "C"]

letters.filter({
(x : String) -> Bool in
println(x)
return true
})


Prints out:



A
B
C
A
B
C


Why does it iterate over the collection twice?



asked 48 secs ago

mythz

52.4k





Aucun commentaire:

Enregistrer un commentaire