I have a class, say Penguin
class Penguin {
var beakLength: Float
}
Trying to sort an array of Penguins
as follows:
let penguins = [Penguin]()
let sortedPenguins = penguins.sort { $0.beakLength < $1.beakLength }
gives error message:
Cannot invoke 'sort' with an argument list of type '(@noescape (Penguin, Penguin) -> Bool)'
Expected an argument list of type '(@noescape (Self.Generator.Element, Self.Generator.Element) -> Bool)'
What am I missing here?
For anyone who has the same problem, it turns out the code sample above wasn't quite correct. What was actually more like:
var sortedPenguins = [Chimp]()
let penguins = [Penguin]()
sortedPenguins = penguins.sort { $0.beakLength < $1.beakLength }
D'oh!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With